SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Find all objects in Server Owned by a Login

By RBarry Young,

In response to a request for a script to show all of the objects on a server onwed by a Login. I didn't know of any tool built-in to do this, so I wrote the following proc (SQL Server 2005 only).

Note the following featues also:

  1. No cursors or other Loops (but total number of databases is limitedt to 255).
  2. If the DB User for a Login is the explicit Owner for an object, then that will be reported.
  3. If there is no explicit owner for an object, then the Login of the DB User that owns the schema containing the object will be returned as the owner.
  4. If there is no explicit owner for an object and the object is contained in the [dbo] schema, then the Login that owns the database will be returned as the object's owner (this is the correct method of assesing object ownership in SQL server 2005).

If the Dynamic SQL concerns you, then notice that the Login name filter is only applied at the end. This means that you could also take the PRINT output and turn it into a static View. If you leave off the Login name WHERE clause, then this view returns every SQL object in your server with it's proper owner. This static View cna be preserved and reused as-is so long as your database configuration does not change.

You could write a SQL Server 2000 version of this also, but it would be significantly different, because of the large changes in the Schema/Owner security model, though probably simpler.

Total article views: 5251 | Views in the last 30 days: 10
Related Articles

How to change object owner......

Change Object Owner


Database owner

Database owner


Database Owner

Database Owner and db_owner


Change all of your database owners

globally change all the database owners on a server.


Table creation with schema owner of current login windows ID.

I want:Schema owner should be dbo instead of windows login id at the time to creating any object.