SQL SERVER Owners of an object

0

I would like to know if there is any way to know the owner of an object in SQL SERVER

    
asked by Cristian Zauco 26.06.2017 в 20:32
source

1 answer

0

You can use the view / table sysobjects that is available from SQL 2000

SELECT  so.name AS 'ObjectName',
    su.name AS 'OwnerName' 
    FROM sysobjects so 
    INNER JOIN sysusers su 
        ON so.uid = su.uid 
    ORDER BY 2,1

This will give you the owners of each of the different objects in the current database, you could eventually filter by so.id if you have the OBJECT_ID of the object or so.name if you have the name, always check the so.xtype to be sure of the type of object.

Note : sysobjects is a view that is maintained for compatibility, the correct thing in new versions would be to use sys.sysobjects

    
answered by 26.06.2017 / 20:40
source