Wednesday, January 18, 2012

Change user login for read only SQL DB

The command to change the login of a DB user with the login of the same name as that of the user, use the following command

sp_change_users_login @Action = ‘Auto_fix’ , @UserNamePattern = ‘username’

In case of Read only DB, u will not able to it by the above command for which case u may change the DB server properties to allow system catolog editing

and then update like below making a link to the online server
update master.dbo.sysxlogins set sid = source.sid from
sourcedbserverlink.master.dbo.sysxlogins source
inner join master.dbo.sysxlogins dest on source.name= dest.name
where source.name=@userid and dest.srvid is null

No comments:

Post a Comment