1234567891011121314151617181920212223242526272829303132333435363738394041 |
- -- =============================================
- -- 程序编写: Jeff
- -- 版 本: V 1.0
- -- 建立日期: 2015-05-11
- -- 功能说明: 只有dindan表有记录,dindanjd无记录的情况下,将所有订单添加一条景点名为"默认景点"的dindanjd记录;
- -- 备 注: 所有订单景点拍照状态都为OK,管理员录入;
- -- 修改日期:
- -- 修改说明:
- -- =============================================
- use [db]
- go
- declare @count int --定义订单数量;
- declare @order nvarchar(32) --定义订单号;
- declare @date nvarchar(16) --定义日期;
- declare @time nvarchar(12) --定义时间;
- declare @waiter1 nvarchar(32) --定义服务员1;
- declare @waiter2 nvarchar(32) --定义服务员2;
- declare @waiter11 nvarchar(32) --定义助理1;
- declare @waiter22 nvarchar(32) --定义助理2;
- declare @bdate nvarchar(32) --定义拍照日期;
- declare @inputtm nvarchar(32) --定义录入时间;
- declare @status nvarchar(4) --定义订单拍照状态
- set @date = datename(year,getdate()) + '-' + datename(month,getdate()) + '-' + datename(day,getdate())
- set @time = datename(hour,getdate()) + ':' + datename(minute,getdate()) + ':' + datename(second,getdate())
- set @inputtm = @date + ' ' + @time
- select identity(int,1,1) as autoid,id,waiter1,waiter2,waiter12,waiter22,time1,[status] into #temp from dindan
- select @count = max(autoid) from #temp
- while( @count > 0)
- begin
- select @order = id, @waiter1 = waiter1, @waiter2 = waiter2, @bdate = time1,@status = [status] from #temp where autoid = @count
- INSERT INTO [dindanjd]([id],[name],[date],[time],[waiter1],[waiter2],[status],[waiter12],[waiter22],[bookingdate],[dress],[bz],[clerk],[inputtime],[branch])
- VALUES(@order,'默认景点',@date,@time,@waiter1,@waiter2,@status,@waiter11,@waiter22,@bdate,'','','admin',@inputtm,'')
- set @count = @count - 1
- end
- drop table #temp
|