Finding Objects Owned by non-DBO Users

  • Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/


    1234

  • Very handy script.

    Note:  I have a few databases with spaces in the name of the database.  This frequently trips up scripts but yours is easy to enhance for such a situation.  Simply change below line:

     , SU.name,SO.name  from '+@dbname+'.dbo.sysobjects SO join '+@dbname+'.dbo.sysusers SU

    to:

     , SU.name,SO.name  from ['+@dbname+'].dbo.sysobjects SO join ['+@dbname+'].dbo.sysusers SU

    Thanks for sharing your code.

    -Mike


    Regards,

    Mike

  • Definitely a handy script.  Although the developers in my company all have dbo privileges to the development database, our Windows Group login is mapped to a user other than dbo.  We are forever creating procedures without specifying the [dbo]. in [dbo].[<procedurename>] and ending up owning the procedure instead of dbo.

    I would make one enhancement to the script. Right after the SET NOCOUNT ON line, I would add this line:

    DELETE FROM [ObjList]

    to prevent duplicates from a previous execution from appearing in the table

  • Mike,

    Thanks for the suggestion.

     

    Santveer


    1234

  • I didn't include DELETE FROM [ObjList] becuase I want to maintain the history also. If some one don't want to maintain the history, he/she may include the DELETE statement. This is just a concept and we can use it in different ways.

    Thanks a lot for your time.


    1234

  • It is a usefull Script; however, I will avoid the cursor.

Viewing 6 posts - 1 through 5 (of 5 total)

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