How To Drop a User in SQL 2005

  • Hello,

    I have a problem on how to drop or deleting a user in SQL 2005.

    "Deleting server logins does not delete the database. It may be necessary to first transfer the ownership of schemas to new users."

    But when using the sp_dropuser '<username>', it returns the following error:

    Msg 15008, Level 16, State 1, Procedure sp_dropuser, Line 12

    User 'offscan' does not exist in the current database.

    Please help me.

    Thanks in advance.

     

    Carmen

  • Hello,

    Anyway, I already did it. Actually my problem was about the sql logins. When restoring a database with a users that has already been established is quite some tedious. I thought that it would be better to drop the user and re-create it again, but I was wrong. Here are the script that I used when fixing the logins:

    USE [dbname]

    GO

    EXEC sp_change_users_login 'Auto_Fix', 'UserName', NULL, 'Userpassword'

    GO

    if not exists (select * from master.dbo.syslogins where name = N'username')

    EXEC sp_grantdbaccess N'username', N'username'

    GO

    exec sp_addrolemember N'db_owner', N'username'

    GO

    Thanks to google. That I found a beautiful solutions to my problem.

    Carmen

  • could you provide us with the source that google found you, or at a minimum the search string you used on google?

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

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