Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Need to know which user is associated with an obje

Author  Topic 

pras2007
Posting Yak Master

216 Posts

Posted - 2010-02-19 : 15:44:48
Hello All,

I want to delete some old logins accounts, and I'm concerned that I maybe deleting an account that is tied to an object in the database. Is there's way to know which user
is associated with an account?

I was able to retrieve an script on the net, but I want to know if there's other ways. The script is shown below:

SELECT s.name AS schema_name, ISNULL(po.name, ps.name) AS object_owner, ISNULL(po.type_desc, ps.type_desc) AS owner_type, o.name, o.object_id, o.principal_id, o.schema_id, o.parent_object_id, o.type, o.type_desc, o.create_date, o.modify_date, o.is_ms_shipped, o.is_published, o.is_schema_published
FROM sys.all_objects AS o INNER JOIN sys.schemas AS s ON o.schema_id = s.schema_id LEFT OUTER JOIN sys.database_principals AS po ON o.principal_id = po.principal_id LEFT OUTER JOIN sys.database_principals AS ps ON s.principal_id = ps.principal_id

Please advice.

Thanks.
   

- Advertisement -