How to find out if the logged in user is a sysadmin member

'sysadmin' is one of the fixed server roles. As stated in SQL Server 2005 Books Online, each member of a fixed server role can add other logins to that same role.

The following query returns the list of available fixed server roles
EXEC sp_helpsrvrole;

Members belonging to the sysadmin server role have the permissions to perform any activity in the server.

In order to find out if the logged in user is a sysadmin:
SELECT IS_SRVROLEMEMBER( 'sysadmin', '' );

Returns 1 if user is a sysadmin, 0 if user is not.

In order to find out the permissions associated with the sysadmin fixed server role:
EXEC sp_srvrolepermission 'sysadmin';

About The Author

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and a new one recently at The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigous Microsoft MVP award for nine times in a row now. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that represents premium web sites and digital publications comprising of Professional web, windows, mobile and cloud developers, technical managers, and architects.

Get in touch with him on Twitter @suprotimagarwal, LinkedIn or befriend him on Facebook

1 comment:

Hemant... said...

Administrators Group is Sysadmin... but member of Administrator group still returns 0 for this query.

Is there any other way to find if user\Group is having sysadmin permission or not ?