处理孤立用户的存储过程
2007-11-11 08:01:45 来源:WEB开发网核心提示:CREATE PROCEDURE [LoneUser]--INPUT@DBName nvarchar(50),@UserName nvarchar(50)AS Exec sp_configure 'allow updates','1' RECONFIGUR
CREATE PROCEDURE [LoneUser]
--INPUT
@DBName nvarchar(50),
@UserName nvarchar(50)
AS
Exec sp_configure 'allow updates','1'
RECONFIGURE WITH OVERRIDE
Declare @ExecStr nvarchar(4000)
Select @ExecStr = ' Declare @b varbinary(85) '
+ ' Use Master'
+ ' Select @b = sid From syslogins Where Name = ''' + @UserName + ''''
+ ' Use ' + @DBName
+ ' Update sysusers Set sid = @b Where name = ''' + @UserName + ''''
--Print @ExecStr
Exec(@ExecStr)
Exec sp_configure 'allow updates','0'
RECONFIGURE WITH OVERRIDE
更多精彩
赞助商链接