Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Checking permissions to a database

Author  Topic 

mksdf
Starting Member

26 Posts

Posted - 2014-09-02 : 05:28:02
Hi,

I have written some code that selects all the databases on our server then uses a while loop to execute some dynamic sql to query a table in each database. The problem is some of the databases dont have the correct permissions so the query breaks. Is it possible to check to see if the database has the correct permissions before I execute the dynamic SQL and if it doesn't move onto the next one in the list? And if so how do I do this?

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-02 : 14:47:30
How about a TRY/CATCH?

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -