Results 1 to 3 of 3

Thread: Drop Users

  1. #1
    Join Date
    Jun 2002
    Posts
    19

    Unanswered: Drop Users

    I know that there is a way to drop a user from one database but not from another. Does sp_drop user do that? To be more specific, I want to drop all users (except for dbo) from one database but not from all others. Is that possible.

  2. #2
    Join Date
    Feb 2002
    Location
    Sweden
    Posts
    34
    If you just wan´t to revoke access for a specific database you can run sp_revokedbaccess 'Username'. You must have selected the database in Query Analyzer first.

    / Jonas
    - Jonte

  3. #3
    Join Date
    Jul 2002
    Location
    Bucharest - Romania
    Posts
    6
    Be sure to execute in quary analyzer and in the database from where you want to drop the users.

    declare @user_name as varchar(100)

    DECLARE CUsers CURSOR FOR
    SELECT name FROM MyTable..sysusers
    where name <> 'dbo'

    OPEN CUsers
    FETCH FROM CUsers INTO @User_Name

    WHILE @@FETCH_STATUS = 0
    BEGIN
    EXEC sp_dropuser @User_Name
    FETCH NEXT FROM CUsers INTO @User_Name
    END

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •