Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

Find Out Server Roles For a SQL Server Login

From Wiki

Jump to: navigation, search

This is a quick way to find out what roles a user has on the SQL Server Just change the value of @chvLoginName to the login you want

  1. DECLARE @chvLoginName VARCHAR(50)
  2. SELECT @chvLoginName='BUILTIN\Administrators'
  3.  
  4. SELECT [name],sysadmin,securityadmin,serveradmin,
  5. setupadmin,processadmin,diskadmin,
  6. dbcreator,bulkadmin,loginname
  7. FROM master..syslogins
  8. WHERE loginname =@chvLoginName

The query below returns all logins whose role is a certain role. The available roles are:

sysadmin
Can perform any activity in SQL Server.

serveradmin
Can set serverwide configuration options, shut down the server.

setupadmin
Can manage linked servers and startup procedures.

securityadmin
Can manage logins and CREATE DATABASE permissions, also read error logs and change passwords.

processadmin
Can manage processes running in SQL Server.

dbcreator
Can create, alter, and drop databases.

diskadmin
Can manage disk files.

bulkadmin
Can execute BULK INSERT statements.

  1. SELECT [name],sysadmin,bulkadmin
  2. FROM master..syslogins
  3. WHERE sysadmin =1 or bulkadmin =1



Contributed by: --SQLDenis 17:14, 7 June 2008 (GMT)


Part of SQL Server Admin Hacks

362 Rating: 0.0/5 (0 votes cast)