Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Bradley Schacht

Bradley is a consultant at Pragmatic Works in Jacksonville, FL. He was an author on the book SharePoint 2010 Business Intelligence 24-Hour Trainer and tech edited the SQL 2011 Bible. His experience on the Microsoft BI platform includes DTS, SSIS, SSRS, SSAS and migrations and conversions. He has helped numerous companies in successfully developing and implementing new business intelligence solutions into their organizations. Bradley also participates as a speaker in community events like SQL Saturday, Code Camp, SQL Lunch and SQL Server User Groups. He is a contributor on sites such as BIDN.com and SQL Server Central as well as an active member of the Jacksonville SQL Server User Group (JSSUG).

Find SQL Database Owner with T-SQL

One thing that on occasion bugs me about PDW or APS or whatever it happens to be called this week is the lack of a UI to do things. I’m not one of those people who has to have a UI to perform operations. I have no problem creating databases, doing backups or creating tables through code. That being said there are times when a UI is helpful to just look up information.

Just today I needed to find out who the database owner was and had to do so through T-SQL. If you look at the sys.databases table you will notice there is an owner_sid column but to the naked eye it is pretty useless. So here is what you need, wrap ownser_sid in syser_sname and you are good to go. Find the code below. Enjoy!

SELECT suser_sname(owner_sid), * FROM sys.databases

Comments

Leave a comment on the original post [www.bradleyschacht.com, opens in a new window]

Loading comments...