Fix Users

,

Fixes Users of a newly restored database (SQL 2000)

-- fix Users
set nocount on
declare @v_dbuser varchar(255)
declare @sql nvarchar(255)
declare c1 cursor for
select a.name from sysusers a, master..syslogins b
where a.name = b.name
	open c1
	fetch c1 into @v_dbuser
	while (@@FETCH_STATUS <> -1)
	BEGIN	
	print 'Fixing User ' + @v_dbuser
	set @sql = 'sp_change_users_login ''auto_fix'',' + @v_dbuser
	exec sp_executesql @sql
	fetch c1 into @v_dbuser
	END
CLOSE C1
DEALLOCATE C1

Rate

3.67 (3)

Share

Share

Rate

3.67 (3)