Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking a users role
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00933646
Message ID:
00933709
Views:
20
>How would I check to see if the current user is part of the admin role?

Hi Kelly,

Take a look at sp_helpsrvrolemember system stored procedure.
DECLARE @username sysname

SET @username = 'sa'

CREATE TABLE #temp (
	ServerRole sysname,
	MemberName sysname,
	MemberSID varbinary(85))

INSERT INTO #temp EXEC sp_helpsrvrolemember 'sysadmin'

SELECT CASE WHEN EXISTS (
		SELECT * FROM #temp 
			WHERE MemberName = @username)
		THEN 'Yes' ELSE 'No' END

DROP TABLE #temp
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform