Quantcast
Viewing all articles
Browse latest Browse all 12963

An invalid parameter or option was specified for procedure 'sys.sp_change_users_login'

Im doing a restore of a production database to a development server.  In the script, right after the restore , I start the following section that I attempt to "re-link" any orphaned users back to their login as a result of the SID getting out of whack.  Mostly, it worked, but for some of the calls to sp_change_users_login generated an error.  

-- RESTORE CODE HERE...using Master

USE SalesDB
DECLARE @user varchar(30), @rowcount integer,@count integer, @uid integer
SELECT @count = COUNT(*) from sysusers
SET @rowcount = 1
SELECT @user = name, @uid = uid FROM sysusers ORDER BY uid ASC
WHILE @rowcount < @count
BEGIN
	IF @user NOT IN('guest','dbo','sys','INFORMATION_SCHEMA')  
	BEGIN
		EXEC sp_change_users_login 'AUTO_FIX',@user
	END
	--print 'NOW FIXING ' + @user
	SELECT @user = name, @uid = uid FROM sysusers
	WHERE uid < @uid
	ORDER BY uid ASC
	SET @rowcount = @rowcount + 1

END
USE master

An invalid parameter or option was specified for procedure 'sys.sp_change_users_login'.
Msg 15600, Level 15, State 1, Procedure sp_change_users_login, Line 207


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>