How to join database user to db_owner role using T-SQL script?
I am using SQL SERVER 2008 R2 Express.
I am working on a new project with a database myDatabase
named db username myUsernamae
.
I would like to use ALTER ROLE
instead sp_addrolemember
because of this post from Microsoft regarding sp_addrolemember (Transact-SQL):
Important. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work and schedule changes to applications that currently use this feature. Use ALTER ROLE instead.
I tried
USE [myDatabase]
GO
ALTER ROLE [db_owner] ADD MEMBER [myUsername]
GO
but I keep getting this error message:
Incorrect syntax near the "ADD" keyword.
What is the correct syntax?
source to share