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 2000 Forums
 Transact-SQL (2000)
 Object owners

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-25 : 09:14:33
Rob writes "I want a query which will list me all database objects owned by a given user.

Is ownership held in a system table, or is there some way of querying who owns a given table?"

izaltsman
A custom title

1139 Posts

Posted - 2002-01-25 : 10:07:43
Yes, ownership information is stored in the system tables.
You could try something along these lines:

select u.name as user_nm, o.name as obj_nm
from sysobjects o inner join sysusers u on o.uid = u.uid
where u.name = 'someuser'

Alternatively you could (and probably should) query the INFORMATION_SCHEMA views rather than system tables. These views are documented in BOL.

Go to Top of Page
   

- Advertisement -