Deleting users from sys.sysusers table in MS 2005

  • How can I delete a bunch of users at the same time from sys.sysusers table in SQL Server 20005 users database?

  • i think your stuck with simply generating the statements as a batch, and then running them:

    like this:

    select'exec sp_dropuser '''+ name + '''' as SQLSTMT, * from sys.sysusers where uid > 3 and uid < 16000

    --or

    select'exec sp_droplogin '''+ name + '''' as SQLSTMT, * from sys.sysusers where uid > 6 and uid < 16000

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • - I think you should post in sql2005 (sys.sysusers)

    - be carefull with users being actual dbowner !

    - be carefull with users owning objects in databases

    - Indeed you need to handle the db-users and the serverlogins separatly.

    Generate your statements !

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Yes.. The above mentioned answers are right. But ensure to have the backup of sysusers table before truncating and adding the values. Take a script of the table and run through the process.

  • Thank you guys! The script works.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply