SQL Query To Delete Empty Accounts

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Omega FragFrog is offline
    MemberRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,630Posts

    SQL Query To Delete Empty Accounts

    Most of you might recognise this: after a while your server has almost as much accounts as it has characters, meaning there are quite a few accounts that never even got used. A waste of good serverspace!
    Now I got quite fed up with that, so decided to make a SQL query which would solve this once and for all, and here it is:


    HOW TO USE:
    Easiest way is with your SQL Query Analyser. Open it (Start -> Programs -> Microsoft SQL Server -> Query Analyzer), login and select the MuOnline database from the drop-down menu on top. Now simply copy-paste the code and press F5 to run it!


    RUN THIS ONLY FIRST TIME!
    Code:
    alter table memb_info 
    add active int
    alter table VI_CURR_INFO
    add active int
    RUN THIS EVERYTIME YOU WANT TO DELETE EMPTY ACCOUNTS
    Code:
    Update dbo.memb_info
    SET active = 0
    Update dbo.memb_info
    SET active = 1 FROM memb_info join Character on memb_info.memb___id=Character.AccountID
    collate Latin1_general_CI_AS
    Update dbo.VI_CURR_INFO
    SET active = 0
    Update dbo.VI_CURR_INFO
    SET active = 1 FROM VI_CURR_INFO join Character on VI_CURR_INFO.memb___id=Character.AccountID
    collate Latin1_general_CI_AS
    SELECT * FROM VI_CURR_INFO join MEMB_INFO on VI_CURR_INFO.memb___id=MEMB_INFO.memb___id
    collate Latin1_general_CI_AS WHERE memb_info.active = 0 AND VI_CURR_INFO.active=0
    DELETE FROM VI_CURR_INFO WHERE VI_CURR_INFO.active=0
    DELETE FROM MEMB_INFO WHERE memb_info.active = 0
    There you go, all accounts that have no characters in them are deleted and you get a nice list of all the deleted accounts! You can even set this as a recurring job, so for instance each week theres a empty-characters sweep :)


    Note: this only works with accounts that have been made with the idreg page of just about every php package i know, which inserts only a new field in the MEMB_INFO and VI_CURR_INFO table.


  2. #2
    Account Upgraded | Title Enabled! themad is offline
    MemberRank
    Dec 2004 Join Date
    BulgariaLocation
    1,018Posts
    fragfrog have u tested this query ? =)

  3. #3
    Account Upgraded | Title Enabled! themad is offline
    MemberRank
    Dec 2004 Join Date
    BulgariaLocation
    1,018Posts
    never mind .. i just did =) nice work

  4. #4
    Account Upgraded | Title Enabled! Backe is offline
    MemberRank
    May 2005 Join Date
    <? Czt ?>Location
    249Posts
    Nice work dude , I just tryed it and it works fine :)

  5. #5
    Omega FragFrog is offline
    MemberRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,630Posts
    Quote Originally Posted by themad
    fragfrog have u tested this query ? =)
    Ofcourse :)

    Works fine here, just NEVER forget the 'where' part when running it or your server might suddenly feel a bit quiet if you get what I mean :D

  6. #6
    Valued Member tyrenn is offline
    MemberRank
    Nov 2004 Join Date
    117Posts
    why delete empty characters? if people will use them later.
    just delete inactive accounts ^^

  7. #7
    Omega FragFrog is offline
    MemberRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,630Posts
    Quote Originally Posted by tyrenn
    why delete empty characters? if people will use them later.
    just delete inactive accounts ^^
    If people will use them later they should make them later. I deleted about 150 accounts in the past week alone. Eventually a big server will have hundrest of unused accounts, meaning other people may not be able to use the name they like because some prick already registred it, and also making the database slower and slower because of unneeded rows.

    And how would you devine an inactive account? Maybe someone is just on holiday for a few weeks, or in hospital. Not really nice to delete their accounts they've worked on for months :icon6:

    Besides, you don't HAVE to use this, you CAN. So why exactley did you even post? Besides spamming the forum with useless comments? You know I haven't seen a single GOOD piece of advice from you in any topic I see you post in; don't criticise the people who release stuff, even if its stuff you don't need yourself.
    Last edited by FragFrog; 20-07-05 at 02:05 AM.

  8. #8
    Account Upgraded | Title Enabled! lesansan is offline
    MemberRank
    Jul 2004 Join Date
    usaLocation
    234Posts
    very good scripts FragFrog.. thank you for saving my hdd spaces.

  9. #9
    Valued Member fiorelloo is offline
    MemberRank
    Apr 2005 Join Date
    MoldovaLocation
    104Posts
    finaly some1 did it

  10. #10
    Valued Member Fallen Angel is offline
    MemberRank
    Apr 2005 Join Date
    undecidedLocation
    119Posts

    Error

    I Got A Error Saying
    Server: Msg 2705, Level 16, State 4, Line 1
    Column names in each table must be unique. Column name 'active' in table 'memb_info' is specified more than once.

  11. #11
    Member _master is offline
    MemberRank
    Oct 2004 Join Date
    MoldovaLocation
    98Posts

    Column exist...

    Quote Originally Posted by Fallen Angel
    I Got A Error Saying
    Server: Msg 2705, Level 16, State 4, Line 1
    Column names in each table must be unique. Column name 'active' in table 'memb_info' is specified more than once.
    ...open you 'memb_info' table, you must have a 'active' column, if is exist, i sugest to delete im and run script again.

  12. #12
    Gamma [GR]SiLvER is offline
    MemberRank
    May 2005 Join Date
    GreeceLocation
    3,074Posts
    WoW i was dreaming of it :angel_inn
    now i wait for the - delete inactive accounts - :)

  13. #13
    Valued Member Fallen Angel is offline
    MemberRank
    Apr 2005 Join Date
    undecidedLocation
    119Posts
    well the inactive acc already exist rite? in guide

  14. #14
    Omega FragFrog is offline
    MemberRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,630Posts
    Quote Originally Posted by Fallen Angel
    I Got A Error Saying
    Server: Msg 2705, Level 16, State 4, Line 1
    Column names in each table must be unique. Column name 'active' in table 'memb_info' is specified more than once.
    You sure you ran the first part of the script only once?

    Since if you try to add another column named 'active' this will indeed cause that error.

  15. #15
    Account Upgraded | Title Enabled! elche27 is offline
    MemberRank
    Dec 2004 Join Date
    TucumanLocation
    302Posts
    Yo bro, FragFrog, nice work and nice share.....my regards!!!



Page 1 of 2 12 LastLast

Advertisement