存储过程中对游标赋值
declare mycursor cursor for------------定义游标
select cloum1,cloum2 from table
open mycursor-----------------打开游标
declare @message varchar(100), @user_id varchar(100), @cityid varchar(100)
FETCH NEXT FROM mycursor INTO @user_id ,@cityid
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @message = 'user: ' + @user_id + 'bbbbb ' + @cityid
PRINT @message
FETCH NEXT FROM mycursor
INTO @user_id1 ,@cityid
end
close mycursor------------------关闭游标
deallocate mycursor------------释放游标
go
select cloum1,cloum2 from table
open mycursor-----------------打开游标
declare @message varchar(100), @user_id varchar(100), @cityid varchar(100)
FETCH NEXT FROM mycursor INTO @user_id ,@cityid
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @message = 'user: ' + @user_id + 'bbbbb ' + @cityid
PRINT @message
FETCH NEXT FROM mycursor
INTO @user_id1 ,@cityid
end
close mycursor------------------关闭游标
deallocate mycursor------------释放游标
go