SqlServer中循環查詢結果集


declare @id int,@value nvarchar(100);
begin
declare c_test_main cursor fast_forward for select hps_hpId,hps_time from hospitalPermSupp where hps_usId=1;
open c_test_main;--打開游標
while 1=1 --開始循環
begin
fetch next from c_test_main into @id,@value; --賦值到變量中
if(@@fetch_status!=0)break;--如果沒有結果退出循環
select @id as a,@value as b
end
close c_test_main --關閉游標
deallocate c_test_main --釋放游標
end


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM