SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sql Script to change the Login Permission


Sql Script to change the Login Permission

Author
Message
virgo
virgo
Old Hand
Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)

Group: General Forum Members
Points: 344 Visits: 520
Hi Guys,

I need a help on SQL Script and not a manual procedure (as i know on it).to do below scenario


1) A login 'testuser' exists on a server which as db_dataread,db_datawrite and db_owner permissions and have around 4 Users tagged to it under 3 different Databases

Datasae1 with user testuser tagged to login testuser
Datasae2 with user testuser tagged to login testuser
Datasae3 with user testuser tagged to login testuser


So now I need a script to

1) Change the permission on login 'testuser' to just db_datareader, db_datawriter, db_ddladmin and execute.


2) After change in permissions on login 'testuser' i hope corresponding users tagged to it on different DBs will also get updated , pls confirm?

Thanks in advance!!!:-)
Oliiii
Oliiii
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1022 Visits: 777
Try this on each dbs:
USE [Datasae1]
GO
EXEC sp_addrolemember N'db_ddladmin', N'testuser'
EXEC sp_droprolemember N'db_owner', N'testuser'
GRANT EXECUTE TO testuser



You have to do it on each DB since you handle the DB security at the DB level Smile
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search