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

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Find Guest user access level in all databases

By Mani Singh,

I used the undocumented sp_MSforeachdb in EXAMPLE:1 to Query all Databases at once in one line code, or you can use a cursor for the same as shown in EXAMPLE:2

There may be other effieient methods and maybe some good use of DMV to same approach, but this is what i use as a Quick Reference, when needed.

I have also included the REVOKE Statement for refrerence, incase you want to remove the Guest access to your Database.

EXAMPLE:3 shows the diff methods to the REVOKE approach.

Just Twisting the Cursor statements a bit, we are able to define a all at onec or one row at a time REVOKE method.

WARNING!!! : TEST this on your TEST- SYSTEM First and use this SCRIPT at your own RISK only.

Study your environment before revoking access to GUEST User.

Total article views: 1272 | Views in the last 30 days: 1
Related Articles

Deny OR Revoke "Drop object" Permission

Deny OR Revoke "Drop object" Permission for particular user


SQL Statment, Pull Object name from database and Revoke

Im trying to Revoke all public SELECT privlages


CLR Table-Valued Function Example with Full Streaming (STVF / TVF)

SQL CLR Table-Valued Functions can stream data back, but there aren't many examples of the quick and...


Triggers Examples

Triggers Examples


The difference between REVOKE and DENY

There was confusion recently with a poster that was moving permissions around and asked why I said t...

guest user    

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones