默认景点名.sql 1.7 KB

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