--从游标取的值 DECLARE @ID VARCHAR(32) DECLARE @UserName VARCHAR(32) --获取待返现数据,并循环处理 DECLARE TestCursor CURSOR FOR SELECT ID,UserName FROM dbo.UserInfo Open TestCursor FETCH NEXT FROM TestCursor INTO @ID,@UserName WHILE @@FETCH_STATUS=0 --当前记录获取成功 BEGIN PRINT GETDATE() PRINT @ID PRINT @UserName FETCH NEXT FROM TestCursor INTO @ID,@UserName END --PRINT 'CLOSE TestCursor' CLOSE TestCursor DEALLOCATE TestCursor