When Alter role i am getting incorrect syntax near the keyword 'ADD' on SQL 2008r2

Hi

Can you please let me know what this command doesn't work in  SQL 2008r2 but it does work in SQL 2012?

Error: Incorrect syntax near the keyword 'ADD'.

How I scan fix this so it would run in SQL 2008r2 ?

use [TESTDB]

CREATE USER [mdy\SF Tech] FOR LOGIN [mdy\SF Tech]
EXEC sp_addrolemember N'db_datareader', N'mdy\SF Tech'
ALTER ROLE db_owner ADD MEMBER [mdy\SF Tech]

-- alter authorization on SCHEMA::[ABOr.AB] to dbo
-- drop all local users
drop user [mdy\bag]
drop user [mdy\Bal]
drop user [mdy\Bhar]
michalek19Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Per the respective MSDN article the ADD and DROP keywords are only valid from SQL Server 2012 onwards.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
For SQL Server 2008 use the sp_addrolemember:
sp_addrolemember 'db_owner', '[mdy\SF Tech]'  

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
michalek19Author Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.