table owner

  • Hello everyone,

    Is there anyway to figure out who the owners of tables are in a database instance of SQL Server 2005? I'm trying to clean up production tables, but I don't want to delete someone else's tables.

    Here what I use:

    select * from sysobjects where type = 'U'

    * Most users log on to sql server using Windows authentication.

    Let me know what you think.

    Thanks,

    Himansu

  • select u.name as UserName,o.name as ObjectName from sys.sysobjects o

    inner join sysusers u

    on u.uid = o.uid

    where [type] = 'u'

    This will get you the ObjectOwner

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Another way...

    SELECT

    [user_name] = USER_NAME(CAST(OBJECTPROPERTYEX(T.[object_id], 'OwnerId') AS INTEGER)),

    [name]

    FROM

    sys.tables T

    ORDER BY

    [user_name],

    [name];

  • Thanks everyone for your reponse.

    * I still get user_name = dbo for all the tables

    The users logon to the SQL Server with their Windows login. I guess there' s no such animal in SQL Server. It makes no sense. Even the ALPHAs have a DIR search by user.

    Thanks,

    Himansu

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply