Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Finding Objects Owned by non-DBO Users


Finding Objects Owned by non-DBO Users

Author
Message
santveer
santveer
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 Visits: 2
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/


1234
Mike Schmidt
Mike Schmidt
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 83

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
CDJorg
CDJorg
SSC Journeyman
SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)

Group: General Forum Members
Points: 90 Visits: 1

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


santveer
santveer
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 Visits: 2

Mike,

Thanks for the suggestion.

Santveer




1234
santveer
santveer
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 Visits: 2

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
Najm Hashmi
Najm Hashmi
Old Hand
Old Hand (362 reputation)Old Hand (362 reputation)Old Hand (362 reputation)Old Hand (362 reputation)Old Hand (362 reputation)Old Hand (362 reputation)Old Hand (362 reputation)Old Hand (362 reputation)

Group: General Forum Members
Points: 362 Visits: 138
It is a usefull Script; however, I will avoid the cursor.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search