将某历史订单还原回当前db数据库中.sql 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. -- 查找2013数据库中指定订单号;
  2. use [2013]
  3. declare @SearchOrder nvarchar(100)
  4. set @SearchOrder = '20110104-027'
  5. select * from client where id = @SearchOrder
  6. select * from dindan where id = @SearchOrder
  7. select * from dindanjd where id = @SearchOrder
  8. select * from dindansp where id = @SearchOrder
  9. select * from dindansp2 where id = @SearchOrder
  10. select * from dindansp3 where id = @SearchOrder
  11. select * from dindanbukuan where id = @SearchOrder
  12. select * from dindanbukuan2 where id = @SearchOrder
  13. select * from burncdreg where id = @SearchOrder
  14. select * from digitalwork where id = @SearchOrder
  15. select * from mywork where id = @SearchOrder
  16. select * from photoprint where id = @SearchOrder
  17. -----------------------------
  18. insert into [db].[dbo].[client] select * from [2013].[dbo].[client] where id = @SearchOrder
  19. insert into [db].[dbo].[dindan] select * from [2013].[dbo].[dindan] where id = @SearchOrder
  20. insert into [db].[dbo].[dindanjd] select * from [2013].[dbo].[dindanjd] where id = @SearchOrder
  21. insert into [db].[dbo].[dindansp]([id],[spid],[shuliang],[kind],[price]
  22. ,[name],[no],[status1],[status2],[status3]
  23. ,[status4],[date1],[date2],[date3],[date4],[name1]
  24. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  25. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  26. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] )
  27. select [id],[spid],[shuliang],[kind],[price]
  28. ,[name],[no],[status1],[status2],[status3]
  29. ,[status4],[date1],[date2],[date3],[date4],[name1]
  30. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  31. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  32. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] from [2013].[dbo].[dindansp] where id = @SearchOrder
  33. insert into [db].[dbo].[dindansp2] select * from [2013].[dbo].[dindansp2] where id = @SearchOrder
  34. insert into [db].[dbo].[dindansp3] select * from [2013].[dbo].[dindansp3] where id = @SearchOrder
  35. insert into [db].[dbo].[dindanbukuan]([id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck],[discount],[time])
  36. select [id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck],[discount],[time]
  37. from [2013].[dbo].[dindanbukuan] where id = @SearchOrder
  38. insert into [db].[dbo].[dindanbukuan2]([id],[money],[ren],[date],[bz],[kind],[ren2])
  39. select [id],[money],[ren],[date],[bz],[kind],[ren2]
  40. from [2013].[dbo].[dindanbukuan2] where id = @SearchOrder
  41. insert into [db].[dbo].[burncdreg] select * from [2013].[dbo].[burncdreg] where id = @SearchOrder
  42. insert into [db].[dbo].[digitalwork] select * from [2013].[dbo].[digitalwork] where id = @SearchOrder
  43. insert into [db].[dbo].[mywork] select * from [2013].[dbo].[mywork] where id = @SearchOrder
  44. insert into [db].[dbo].[photoprint] select * from [2013].[dbo].[photoprint] where id =@SearchOrder