SQL SERVER 游标
DECLARE @ID nchar(200)
, @BU nchar(200)
, @Productname NVARCHAR(1000)
, @Producttype NVARCHAR(1000)
, @ref_num nchar(200)
, @producttype1 nchar(200)
, @producttype2 nchar(200)
, @reviewer NVARCHAR(1000)
, @review_dept NVARCHAR(1000)
, @re_date date;
DECLARE mycursor CURSOR
FOR
SELECT ID,BU,Productname,Producttype,ref_num,producttype1,producttype2,reviewer,review_dept,re_date FROM ra_demo
OPEN mycursor
FETCH NEXT FROM mycursor INTO @ID, @BU,@Productname,@Producttype,@ref_num,@producttype1,@producttype2,@reviewer,@review_dept,@re_date;
WHILE @@fetch_status = 0
BEGIN
INSERT INTO ra_device(ID,BU,Productname,Producttype,ref_num,producttype1,producttype2,reviewer,review_dept,re_date)VALUES(@ID, @BU,@Productname,@Producttype,@ref_num,@producttype1,@producttype2,@reviewer,@review_dept,@re_date);
FETCH NEXT FROM mycursor INTO @ID, @BU,@Productname,@Producttype,@ref_num,@producttype1,@producttype2,@reviewer,@review_dept,@re_date;
END
CLOSE mycursor;
DEALLOCATE mycursor;