sql curse游标
--加行号
select row_number() over(order by getdate()) sevencode from #promprod
-- 存入表中
create table #promprod (sevencode nvarchar(20))
insert into #promprod values ('0063173')
insert into #promprod values ('0057584')
insert into #promprod values ('0058495')
insert into #promprod values ('0058510')
insert into #promprod values ('0076541')
insert into #promprod values ('0097968')
create table #t(id int,value nvarchar(20));
declare @date1 varchar(10)
declare @date2 varchar(10)
declare @date3 varchar(10)
declare @date4 varchar(10)
declare @date5 varchar(10)
declare @date6 varchar(10)
declare @d varchar(10)
declare mycursor cursor for
select sevencode from #promprod
open mycursor
fetch from mycursor into @date1
declare @i int
declare @sql nvarchar(4000)
set @i=1
while (@@FETCH_STATUS=0)
begin
set @i=@i+1
fetch next from mycursor into @d;
insert into #t select @i,@d;
set @d='';
end
close mycursor;
deallocate mycursor;
select * from #t;
drop table #t,#promprod