question

shashi avatar image
shashi asked

How do I add multiple users to a role in one statement? If it is SQL Authentication?

Hi,

How do I add multiple users to a role in one statement? If it is SQL Authentication?

sql-server-2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Magnus Ahlkvist avatar image
Magnus Ahlkvist answered

The simple answer is you don't. You can only add one user at the time.

ALTER ROLE <rolename> ADD MEMBER <username>;

ALTER ROLE can only add one member.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeff Moden avatar image
Jeff Moden answered

Magnus is correct but... you should ALWAYS look things up in the documentation when it comes to matters of security. With the idea of teach someone to fish, here's the link to get you started. https://www.google.com/search?q=SQL+Server+ALTER+ROLE

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

agsfhdfhdhfdh

0 Likes 0 ·
anthony.green avatar image
anthony.green answered

If your allowed to use DBATools and Add-DbaDbRoleMember and pass in a comma separated list of values to the -User parameter

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.