Results 1 to 2 of 2

Thread: [RESOLVED] Problem Adding User to Role

  1. #1

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,279

    Resolved [RESOLVED] Problem Adding User to Role

    In SQL Server Express something (I forget which version, but something fairly recent, like 2017, if that's possible), I'm trying to write a script to add users and assign some roles to them. Adding the user is working, but then I attempt to assign a role using this:

    ALTER ROLE db_datareader ADD MEMBER HISAppLogin

    Which appears to be right according to a variety of sites, yet I'm getting an error on the ADD, with the error message saying that WITH is expected. The line is taken straight from the MS documentation, and is confirmed on a variety of other sites, so I'm not sure what I am doing wrong. I can see that WITH is an option, but it's an option for doing something that doesn't seem right. So...what am I doing wrong?
    My usual boring signature: Nothing

  2. #2

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,279

    Re: [RESOLVED] Problem Adding User to Role

    Well, nevermind. Turns out, I was connecting to the wrong database. I was connecting to a 2008/R2 instance that probably got installed along with VS2010, or something like that. The ALTER ROLE statement doesn't work that far back, and a stored procedure must be used, instead. Since I was on the wrong SQL Server instance, it wasn't running, and that might have been a good thing.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width