//自定義字符串
declare @orderNum varchar(255)
//創(chuàng)建虛擬表
create table #ttableName(id int identity(1,1),Orders varchar(255))
//自定義自然數(shù)和行數(shù)
declare @n int,@rows int
//將要操作的數(shù)據(jù)查詢出來,插入到創(chuàng)建的虛擬表鐘
insert #ttableName(orders) select userID from DEV_USER where USERID not in (select CODE_OPT from SYS_MKQXOPT where SYS_CODE = '05')
--select @rows=count(1) from pe_Orders
//將行數(shù)賦予rows自定義行數(shù)
select @rows =@@rowcount
//自然數(shù)n賦值為1
set @n=1
//while循環(huán)皿渗,當(dāng)自然數(shù)n小于等于行數(shù)時(shí)執(zhí)行循環(huán)
while @n<=@rows
//開始
begin
//此處操作虛擬表查出第n行數(shù)據(jù)凛捏,用于操作數(shù)據(jù)
insert into SYS_MKQXOPT (CODE_OPT,SYS_CODE,Type) values ((select Orders from #ttableName where id=@n),'05','1')
//打印字符串
print (@OrderNum)
//n即行數(shù)+1
select @n=@n+1
//結(jié)束
end
//刪除虛擬表
drop table #ttableName