日期:2014-05-18  浏览次数:20472 次

??求教--存储过程中的简单赋值???
select   id,card   from   user   where   id   =5
declare   @i   bigint,@j   bigint
----下面的语句要用上面select出来的值,赋值给两个变量??
----好像行不通!(存储过程)该怎么处理
set   @i=id
set   @j=card  


--------------------
上面的变量@i和@j怎么赋值呀?它们的值要从user表中查询!上面的写法是错的!


------解决方案--------------------
select @i=id,@j=card from [user] where id=5
------解决方案--------------------
select @i=id,@j=card from [user] where id=5

------解决方案--------------------
谢谢了,
还有一个问题是;
如何循环迭代出表中的数据??
select @i=id,@j=card from [user]
这时 有很多的数据出现!

do{}
where()
语句吗?
-----------------------

--遍历数据用游标

declare curTest cursor for select id,card from [user]
open curTest --打开游标
fetch next from curTest into @id,@j--顺序提取行
while @@fetch_status=0
begin
--处理部分
fetch next from curTest into @id,@j
end
close curTest
deallocate curTest