[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

User has lost Login Name

Posted on 2006-03-23
4
Medium Priority
?
1,121 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:JordanKingsley
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 16272112
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
0
 

Author Comment

by:JordanKingsley
ID: 16272393
I'm sure I understand what that did. How do I delete that user?
0
 
LVL 10

Expert Comment

by:PSSUser
ID: 16272453
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.
0
 

Author Comment

by:JordanKingsley
ID: 16272543
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"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question