DECLARE Curusers CURSOR LOCAL FOR
SELECT Tp_Login, Tp_Systemid FROM Userinfo Where Tp_Deleted = 0
OPEN Curusers
FETCH NEXT FROM Curusers INTO @Login, @Systemid
WHILE @@FETCH_STATUS = 0
BEGIN
Begin Try
PRINT 'Resetting Login ' + @Login + ' To New Login '
Update Userinfo Set Tp_Login=Replace(Tp_Login, '旧域名\','新域名\')
WHERE CURRENT OF Curusers
End Try
Begin Catch
PRINT 'Resetting Login ' + @Login + ' Failed! '
PRINT Error_Message()
End Catch
Begin Try
PRINT 'Resetting SID ' + @Login + ' To New SID '
PRINT Suser_Sid(@Login)
UPDATE Userinfo SET Tp_Systemid = Suser_Sid(Tp_Login)
WHERE CURRENT OF Curusers
End Try
Begin Catch
PRINT 'Resetting SID ' + @Login + ' Failed! '
PRINT Error_Message()
End Catch
FETCH NEXT FROM Curusers INTO @Login, @Systemid
END
CLOSE Curusers
DEALLOCATE Curusers