Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:24:51+00:00 2026-06-13T17:24:51+00:00

I need a T-SQL statement to check if a user is member of a

  • 0

I need a T-SQL statement to check if a user is member of a database role in SQL Server. Specifically I need to know if the user is member of the dbo role, because then I don’t have to grant additional authority to that user.

If I try to add additional authority when the user is dbo it fails, and my script fails…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:24:52+00:00Added an answer on June 13, 2026 at 5:24 pm

    This is what I ended up doing: (edit based on comment)

    DECLARE @ISSYSADMIN INT
    SET @ISSYSADMIN = (SELECT COUNT(1) 
                       FROM sys.syslogins 
                       WHERE sysadmin = 1 AND loginname = '$(ContentAccount)')
    

    The $(ContentAccount) is of course a parametrization which has the user domain and name!

    This solves my problem because when we deploy a new database we are assigning permissions manually. But in development environments where the user we try to add already is sysadmin they fail. So if we check for sysadmin membership that is enough to cover the dev server scenario.

    Then I do this to check membership:

    IF (@ISSYSADMIN = 0)
    BEGIN
      -- Add authority
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server, you need to check error for each SQL statement. For example
I need an SQL statement that check if one condition is satisfied: SELECT *
I need to check whether a column is NOT NULL in my SQL statement.
I am programatically generating a SQL statement that I then need to execute, however
I need to add transactions for a sql statement in a database application, up
I need to convert a sql statement to a linq query. The code below
This SQL statement example is very close to what I think I need... update
I have a SQL Statement where i need to display the value from another
I need to write the following SQL statement in LINQ lambdas : SELECT *
I have a dynamic SQL statement I've created in a stored procedure. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.