Wednesday, April 13, 2011

Interested to know a command to see all the SQL server roles? Easy.

Easy to do, just execute the following query:
SELECT r.name AS [Name], 'Server[@Name=' + quotename(CAST( serverproperty(N'Servername') AS sysname),'''') + ']' + '/Role[@Name=' + quotename(r.name,'''') + ']' AS [Urn] FROM sys.server_principals r WHERE (r.type ='R') ORDER BY [Name] ASC
Results:

No comments:

Post a Comment