DECLARE @stuId NVARCHAR(20)
--声明变量
DECLARE @stuName NVARCHAR(20)
DECLARE userCur CURSOR
FOR
SELECT [User_Name] ,
[User_Pwd]
FROM dbo.T_baseSys_User
--声明游标
OPEN userCur
--打开游标
FETCH NEXT FROM userCur INTO @stuId, @stuName
--取,填充
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'ID:' + @stuId + '用户名' + @stuName
FETCH NEXT FROM userCur INTO @stuId, @stuName
END
CLOSE userCur
--关闭游标
DEALLOCATE userCur --释放游标
sql server 游标使用
最新推荐文章于 2023-01-11 09:46:39 发布