Can't add user to a role

Konrad Viltersten

I follow the MS guidelines and they give a specific example as follows.

ALTER ROLE Sales ADD MEMBER Barry;

However, when I perform corresponding operation, I get an error telling me that "Incorrect syntax near the keyword 'ADD'" and a line under the keyword ADD. When I hover over it, I can see that the tooltip says "Expecting WITH".

As far I can see, WITH is used for other alternation that addition of users to roles. So my question is twofold.

  1. What can I do to add the user to the role?
  2. What's upp with the misguided tooltip?

Somewhere else on the internet, I've seen that the users are added to roles by calling a stored procedure instead. That begs a question what the MSDN link is talking about - as if it's not possible to use that script. Suggestions are welcome on the subjects as I'm less than experienced with DBs and feel like a moose on the ice.

My config: Microsoft SQL Server Management Studio 10.50.4000.0
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 9.0.8112.16421
Microsoft .NET Framework 2.0.50727.5466
Operating System 6.1.7601

Stu

What verion of SQL are you using? The syntax you have will only work in 2012 onwards

Instead you should execute the sp_addrolemember:

EXEC sp_addrolemember 'Sales', 'Barry'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related