-
-
Notifications
You must be signed in to change notification settings - Fork 15
Change sp_addrolemember to ALTER ROLE #384
Copy link
Copy link
Closed
Description
The sp_addrolemember in SQL will be removed in future. You probably know!
I was automating some work and took some of your DB permissions code to do it. The sp_addrolemember gave me some issues with roles already being assigned. I changed it to the ALTER ROLE and the problem was solved.
Change
SqlCommand addRoleMember = new SqlCommand($"sp_addrolemember 'db_owner', '{appPoolName}'", myConn);
to
SqlCommand addRoleMember = new SqlCommand($"ALTER ROLE [db_owner] ADD MEMBER [{appPoolName}] ", myConn);
Reactions are currently unavailable