
- --创建变量
- declare @sql varchar(300);
- declare @StoreID varchar(50), @GroupName varchar(50),@GroupID int,@Sku varchar(50),
- @ItemName varchar(100),@ProDate nvarchar(20),@ShelfLife nvarchar(20),@OverDays int,@CreatTime varchar(50) ,@IsSend smallint
- --创建游标
- declare cursor1 cursor for select [StoreID],[GroupName],[GroupID],[Sku],[ItemName],[ProDate],[ShelfLife],[OverDays],CONVERT(varchar(50),[CreatTime],120),[IsSend] from dbo.F_OverTime
- --打开游标
- open cursor1
- --游标赋值
- fetch next from cursor1 into @StoreID , @GroupName ,@GroupID ,@Sku ,@ItemName ,@ProDate ,@ShelfLife ,@OverDays ,@CreatTime ,@IsSend
- while @@fetch_status=0
- begin
- set @sql='INSERT INTO [F_OverTime] VALUES ('''+@StoreID+''', '''+@GroupName+''','+Cast(@GroupID as nvarchar(50))+','''+@Sku+''','''+@ItemName+''','''+@ProDate+''','''+@ShelfLife+''','+Cast(@OverDays as nvarchar(50))+','''+ @CreatTime +''','+Cast(@IsSend as nvarchar(50))+')'
- print @sql
- fetch next from cursor1 into @StoreID , @GroupName ,@GroupID ,@Sku ,@ItemName ,@ProDate ,@ShelfLife ,@OverDays ,@CreatTime ,@IsSend
- end
- close cursor1
- deallocate cursor1