User has lost Login Name

Hello all. We have a Citrix database with a server login called Citrix_User, and User in that database with the same name. I had to restart the server yesterday to swap some drives. Today when I go to the properties of Citrix_User in the database the login shows <none>. When I try and delete that user it says "The selected user cannot be dropped because the user owns objects". Can you guys tell me how to both get that login back and how to delete the user account (I've created another one that Citrix is now using, but need to know in case that happens again).  Thanks, Jordan
JordanKingsleyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
Hi JordanKingsley,
in order to change the ownership of the objects you can use the following

DECLARE @old sysname, @new sysname, @sql varchar(1000)
SELECT @old = 'Citrix_User' ,
@new = 'dbo' ,
@sql = ' IF EXISTS (SELECT NULL FROM INFORMATION_SCHEMA.TABLES WHERE QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME) = ''?'' AND TABLE_SCHEMA = ''' + @old + ''' )

EXECUTE sp_changeobjectowner ''?'', ''' + @new + ''''EXECUTE sp_MSforeachtable @sql


then try to recreate the login

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JordanKingsleyAuthor Commented:
I'm sure I understand what that did. How do I delete that user?
PSSUserCommented:
In order to be able to log in with the user you should just need to set the (default) database to a valid database. This normally gets set to none if the database that was originally the user's default database has been dropped. This includes if the database was dropped and re-created.
JordanKingsleyAuthor Commented:
I see, but how to I delete a user that I don't need anymore and I still get the message:

"The selected user cannot be dropped because the user owns objects"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.