转历史时丢了的订单从备份数据库里插入回db数据库里.sql 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. -- 转历史时丢了的订单从备份数据库里插入回db数据库里;
  2. -- 关联12张表;
  3. -- 步骤:新建数据库back,然后从备份里还原,把以下命令的id='...'单引号内的订单改成要插回db里的订单,再执行。
  4. --1.dindansp表;
  5. set IDENTITY_INSERT [db].[dbo].[dindansp] ON
  6. insert into [db].[dbo].[dindansp]
  7. ([id]
  8. ,[spid]
  9. ,[shuliang]
  10. ,[kind]
  11. ,[price]
  12. ,[name]
  13. ,[no]
  14. ,[status1]
  15. ,[status2]
  16. ,[status3]
  17. ,[status4]
  18. ,[autoid]
  19. ,[date1]
  20. ,[date2]
  21. ,[date3]
  22. ,[date4]
  23. ,[name1]
  24. ,[name2]
  25. ,[name3]
  26. ,[name4]
  27. ,[hqdate]
  28. ,[hqtime]
  29. ,[urgent]
  30. ,[taketime]
  31. ,[no2]
  32. ,[status5]
  33. ,[status6]
  34. ,[date5]
  35. ,[date6]
  36. ,[name5]
  37. ,[name6]
  38. ,[growthtxname]
  39. ,[ps]
  40. ,[zs]
  41. ,[ren1]
  42. ,[ren2]
  43. ,[hqstatus]
  44. ,[bz]) select * from [back].[dbo].[dindansp] where id='111111'
  45. SET IDENTITY_INSERT [db].[dbo].[dindansp] OFF
  46. --2.dindanbukuan表;
  47. set IDENTITY_INSERT [db].[dbo].[dindanbukuan] ON
  48. insert into [db].[dbo].[dindanbukuan] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck] from [back].[dbo].[dindanbukuan] where id='111111'
  49. SET IDENTITY_INSERT [db].[dbo].[dindanbukuan] OFF
  50. --3.dindanbukuan2表;
  51. set IDENTITY_INSERT [db].[dbo].[dindanbukuan2] ON
  52. insert into [db].[dbo].[dindanbukuan2] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2] from [back].[dbo].[dindanbukuan2] where id='111111'
  53. SET IDENTITY_INSERT [db].[dbo].[dindanbukuan2] OFF
  54. --4.dindan表;
  55. insert into [db].[dbo].[dindan] select * from [back].[dbo].[dindan] where id='111111'
  56. --5.photoprint表;
  57. insert into [db].[dbo].[photoprint] select * from [back].[dbo].[photoprint] where id='111111'
  58. --6.client表;
  59. insert into [db].[dbo].[client] select * from [back].[dbo].[client] where id='111111'
  60. --7.burncdreg表;
  61. insert into [db].[dbo].[burncdreg] select * from [back].[dbo].[burncdreg] where id='111111'
  62. --8.digitalwork表;
  63. insert into [db].[dbo].[digitalwork] select * from [back].[dbo].[digitalwork] where id='111111'
  64. --9.mywork;
  65. insert into [db].[dbo].[mywork] select * from [back].[dbo].[mywork] where id='111111'
  66. --10.dindanjd表;
  67. insert into [db].[dbo].[dindanjd] select * from [back].[dbo].[dindanjd] where id='111111'
  68. --11.dindansp2表;
  69. insert into [db].[dbo].[dindansp2] select * from [back].[dbo].[dindansp2] where id='111111'
  70. --12.dindansp3表;
  71. insert into [db].[dbo].[dindansp3] select * from [back].[dbo].[dindansp3] where id='111111'