mssql游标demo

declare @billIds varchar(400)
declare @billId varchar(40)
DECLARE c1 CURSOR FOR
select top 5 SaleNo from Pos_Master where SaleDate>@dd -- 一次上传5笔
open c1
FETCH NEXT FROM c1 INTO @billId
WHILE @@FETCH_STATUS = 0
BEGIN
if @billIds is null begin
set @billIds=‘‘‘‘+@billId+‘‘‘‘
end else begin
set @billIds=@billIds+‘,‘+‘‘‘‘+@billId+‘‘‘‘
end
FETCH NEXT FROM c1 INTO @billId
end
close c1
deallocate c1

mssql游标demo,布布扣,bubuko.com

mssql游标demo

上一篇:Oracle取月份-不带前面的0


下一篇:sql SELECT时的with(nolock)选项说明