-- Script to check the orphan userEXEC sp_change_users_login 'Report'--Use below code to fix the Orphan User issueDECLARE @username varchar(25)DECLARE fixusers CURSORFORSELECT UserName = name FROM sysusersWHERE issqluser = 1 and (sid is not null and sid <> 0x0)and suser_sname(sid) is nullORDER BY nameOPEN fixusersFETCH NEXT FROM fixusersINTO @usernameWHILE @@FETCH_STATUS = 0BEGINEXEC sp_change_users_login 'update_one', @username, @usernameFETCH NEXT FROM fixusersINTO @usernameENDCLOSE fixusersDEALLOCATE fixusers
Post a Comment
Post a Comment