Dropping all users

  • I am creating a bunch of jobs that restore our prod dbs to our test and deve environments nightly. I'd like to include in that job a step that drops all users and their permissions, then the following step would grant only permissions to the users that need it on test and dev.

    My question is - Is there any way to drop all users without having to specify each user. I know I can say sp_dropuser 'Bob'

    sp_dropuser 'Tom'

    But I would rather just run one that would drop all. Is there anything I can use? Thanks!

    Thanks!

  • How about

    SELECT * FROM sys.sysusers WHERE uid>5 AND SUBSTRING(name,1,2)<>'db'

  • I would recommend sp_revokedbaccess rather sp_dropuser

    ---------------------------------------------------------------------

Viewing 3 posts - 1 through 2 (of 2 total)

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