Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check if user has system admin privileges in SQL Server 2008 R2

I have a application that should only allow access to users who are system admins on the db. What sql script or query can I execute from the c# code that, given a username, can determine if he/she has system admin privileges system specs: sql2008R2 db, .net 2.0, c#

like image 580
EndlessSpace Avatar asked Dec 09 '10 19:12

EndlessSpace


1 Answers

Use IS_SRVROLEMEMBER.

SELECT IS_SRVROLEMEMBER('sysadmin', 'YourLogin')
like image 137
Joe Stefanelli Avatar answered Oct 13 '22 01:10

Joe Stefanelli