Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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)

Security Queries: Database-level

By Greg Drake,

This script contains various queries I have written on the subject of security as it applies to a specific database. It's arranged so I can either (A) run one query I need alone or (B) run the whole thing as a batch to dump out everything at once.

Option B might not seem useful at first (information overload!), but consider that if your output in SSMS is set to "Results to Text", this will allow you to quickly copy off a single text file that contains everything you might want to know about that database's security at a point in time. Furthermore, the queries are carefully structured and ordered to be consistent. This makes two of these text files easy to compare with a standard compare/diff/merge application (e.g. WinMerge, Beyond Compare).

Included queries:

  • Database roles
  • Database users
  • Database role membership
  • Database role and user permissions
  • Database-level SQL/Assembly module EXECUTE AS
  • Schema ownership
  • Individual ownership of database objects if not owned by schema
  • Database users linked to server login
  • Database users that were linked to server login, but are not anymore

The last query is a re-write of the 'report' mode of sp_change_users_login.

Please also see related script Security Queries: Server-level.

Total article views: 3243 | Views in the last 30 days: 11
 
Related Articles
FORUM

how to back up and restore security user login [database logins] from sql 2000 to sql 2005 x64

back up and restore security user login [database logins]

FORUM

Secure Login

Secure Mechanism For Customer Login page

FORUM

Separate Login for a query in a stored procedure

separate login for query

SCRIPT

Security Queries: Server-level

A set of queries which attempt to gather as much security-related information on a server instance a...

SCRIPT

SQL Server Security Extract (Reverse Engineer) for ALL Databases

These scripts will extract security for Windows Logins, Database Users, Roles, Objects and SQL Login...

Tags
auditing    
comparison    
logins    
members    
ownership    
permissions    
principals    
role    
roles    
secure    
security    
user    
 
Contribute