从备份中恢复订单数据.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /************************************************************************/
  2. /*
  3. 程序编写: Jeff
  4. 版 本: V 1.0
  5. 建立日期: 2015-06-02
  6. 功能说明: 从备份中恢复订单数据;
  7. 备 注:
  8. 修改日期:
  9. 修改说明:
  10. */
  11. /************************************************************************/
  12. select * from client where id = '20130809-027'
  13. select * from dindan where id = '20130809-027'
  14. select * from dindanjd where id = '20130809-027'
  15. select * from dindansp where id = '20130809-027'
  16. select * from dindansp2 where id = '20130809-027'
  17. select * from dindansp3 where id = '20130809-027'
  18. select * from dindanbukuan where id = '20130809-027'
  19. select * from dindanbukuan2 where id = '20130809-027'
  20. select * from burncdreg where id = '20130809-027'
  21. select * from digitalwork where id = '20130809-027'
  22. select * from mywork where id = '20130809-027'
  23. select * from photoprint where id = '20130809-027'
  24. DECLARE @bak_db nvarchar(50) -- 备份的数据库;
  25. DECLARE @cur_db nvarchar(50) -- 当前的数据库;
  26. DECLARE @count int -- 指定订单数量;
  27. set @bak_db = '2012'
  28. set @cur_db = 'db'
  29. insert into [bak].[dbo].[client] select * from [db].[dbo].[client] where id in(
  30. '20150302-012','20150310-021',
  31. '20150312-029','20150327-022',
  32. '20150327-023','20150327-024',
  33. '20150328-034','20150328-035',
  34. '20150328-036','20150328-037',
  35. '20150328-038','20150328-039',
  36. '20150328-040','20150328-043',
  37. '20150328-047','20150328-048',
  38. '20150328-049','20150329-020',
  39. '20150329-112','20150513-002',
  40. '20150513-008','20150513-009',
  41. '20150513-010','20150513-011',
  42. '20150513-012','20150513-013',
  43. '20150513-018','20150514-002',
  44. '20150514-007','20150514-008',
  45. '20150514-009','20150514-010'
  46. )
  47. insert into [bak].[dbo].[dindan] select * from [db].[dbo].[dindan] where id in(
  48. '20150302-012','20150310-021',
  49. '20150312-029','20150327-022',
  50. '20150327-023','20150327-024',
  51. '20150328-034','20150328-035',
  52. '20150328-036','20150328-037',
  53. '20150328-038','20150328-039',
  54. '20150328-040','20150328-043',
  55. '20150328-047','20150328-048',
  56. '20150328-049','20150329-020',
  57. '20150329-112','20150513-002',
  58. '20150513-008','20150513-009',
  59. '20150513-010','20150513-011',
  60. '20150513-012','20150513-013',
  61. '20150513-018','20150514-002',
  62. '20150514-007','20150514-008',
  63. '20150514-009','20150514-010'
  64. )
  65. insert into [bak].[dbo].[dindanjd] select * from [db].[dbo].[dindanjd] where id in(
  66. '20150302-012','20150310-021',
  67. '20150312-029','20150327-022',
  68. '20150327-023','20150327-024',
  69. '20150328-034','20150328-035',
  70. '20150328-036','20150328-037',
  71. '20150328-038','20150328-039',
  72. '20150328-040','20150328-043',
  73. '20150328-047','20150328-048',
  74. '20150328-049','20150329-020',
  75. '20150329-112','20150513-002',
  76. '20150513-008','20150513-009',
  77. '20150513-010','20150513-011',
  78. '20150513-012','20150513-013',
  79. '20150513-018','20150514-002',
  80. '20150514-007','20150514-008',
  81. '20150514-009','20150514-010'
  82. )
  83. insert into [bak].[dbo].[dindansp]([id],[spid],[shuliang],[kind],[price]
  84. ,[name],[no],[status1],[status2],[status3]
  85. ,[status4],[date1],[date2],[date3],[date4],[name1]
  86. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  87. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  88. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] )
  89. select [id],[spid],[shuliang],[kind],[price]
  90. ,[name],[no],[status1],[status2],[status3]
  91. ,[status4],[date1],[date2],[date3],[date4],[name1]
  92. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  93. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  94. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] from [db].[dbo].[dindansp] where id in(
  95. '20150302-012','20150310-021',
  96. '20150312-029','20150327-022',
  97. '20150327-023','20150327-024',
  98. '20150328-034','20150328-035',
  99. '20150328-036','20150328-037',
  100. '20150328-038','20150328-039',
  101. '20150328-040','20150328-043',
  102. '20150328-047','20150328-048',
  103. '20150328-049','20150329-020',
  104. '20150329-112','20150513-002',
  105. '20150513-008','20150513-009',
  106. '20150513-010','20150513-011',
  107. '20150513-012','20150513-013',
  108. '20150513-018','20150514-002',
  109. '20150514-007','20150514-008',
  110. '20150514-009','20150514-010'
  111. )
  112. insert into [bak].[dbo].[dindansp2] select * from [db].[dbo].[dindansp2] where id in(
  113. '20150302-012','20150310-021',
  114. '20150312-029','20150327-022',
  115. '20150327-023','20150327-024',
  116. '20150328-034','20150328-035',
  117. '20150328-036','20150328-037',
  118. '20150328-038','20150328-039',
  119. '20150328-040','20150328-043',
  120. '20150328-047','20150328-048',
  121. '20150328-049','20150329-020',
  122. '20150329-112','20150513-002',
  123. '20150513-008','20150513-009',
  124. '20150513-010','20150513-011',
  125. '20150513-012','20150513-013',
  126. '20150513-018','20150514-002',
  127. '20150514-007','20150514-008',
  128. '20150514-009','20150514-010'
  129. )
  130. insert into [bak].[dbo].[dindansp3] select * from [db].[dbo].[dindansp3] where id in(
  131. '20150302-012','20150310-021',
  132. '20150312-029','20150327-022',
  133. '20150327-023','20150327-024',
  134. '20150328-034','20150328-035',
  135. '20150328-036','20150328-037',
  136. '20150328-038','20150328-039',
  137. '20150328-040','20150328-043',
  138. '20150328-047','20150328-048',
  139. '20150328-049','20150329-020',
  140. '20150329-112','20150513-002',
  141. '20150513-008','20150513-009',
  142. '20150513-010','20150513-011',
  143. '20150513-012','20150513-013',
  144. '20150513-018','20150514-002',
  145. '20150514-007','20150514-008',
  146. '20150514-009','20150514-010'
  147. )
  148. insert into [bak].[dbo].[dindanbukuan]([id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck],[discount],[time])
  149. select [id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck],[discount],[time]
  150. from [db].[dbo].[dindanbukuan] where id in(
  151. '20150302-012','20150310-021',
  152. '20150312-029','20150327-022',
  153. '20150327-023','20150327-024',
  154. '20150328-034','20150328-035',
  155. '20150328-036','20150328-037',
  156. '20150328-038','20150328-039',
  157. '20150328-040','20150328-043',
  158. '20150328-047','20150328-048',
  159. '20150328-049','20150329-020',
  160. '20150329-112','20150513-002',
  161. '20150513-008','20150513-009',
  162. '20150513-010','20150513-011',
  163. '20150513-012','20150513-013',
  164. '20150513-018','20150514-002',
  165. '20150514-007','20150514-008',
  166. '20150514-009','20150514-010'
  167. )
  168. insert into [bak].[dbo].[dindanbukuan2]([id],[money],[ren],[date],[bz],[kind],[ren2])
  169. select [id],[money],[ren],[date],[bz],[kind],[ren2]
  170. from [db].[dbo].[dindanbukuan2] where id in(
  171. '20150302-012','20150310-021',
  172. '20150312-029','20150327-022',
  173. '20150327-023','20150327-024',
  174. '20150328-034','20150328-035',
  175. '20150328-036','20150328-037',
  176. '20150328-038','20150328-039',
  177. '20150328-040','20150328-043',
  178. '20150328-047','20150328-048',
  179. '20150328-049','20150329-020',
  180. '20150329-112','20150513-002',
  181. '20150513-008','20150513-009',
  182. '20150513-010','20150513-011',
  183. '20150513-012','20150513-013',
  184. '20150513-018','20150514-002',
  185. '20150514-007','20150514-008',
  186. '20150514-009','20150514-010'
  187. )
  188. insert into [bak].[dbo].[burncdreg] select * from [db].[dbo].[burncdreg] where id in(
  189. '20150302-012','20150310-021',
  190. '20150312-029','20150327-022',
  191. '20150327-023','20150327-024',
  192. '20150328-034','20150328-035',
  193. '20150328-036','20150328-037',
  194. '20150328-038','20150328-039',
  195. '20150328-040','20150328-043',
  196. '20150328-047','20150328-048',
  197. '20150328-049','20150329-020',
  198. '20150329-112','20150513-002',
  199. '20150513-008','20150513-009',
  200. '20150513-010','20150513-011',
  201. '20150513-012','20150513-013',
  202. '20150513-018','20150514-002',
  203. '20150514-007','20150514-008',
  204. '20150514-009','20150514-010'
  205. )
  206. insert into [bak].[dbo].[digitalwork] select * from [db].[dbo].[digitalwork] where id in(
  207. '20150302-012','20150310-021',
  208. '20150312-029','20150327-022',
  209. '20150327-023','20150327-024',
  210. '20150328-034','20150328-035',
  211. '20150328-036','20150328-037',
  212. '20150328-038','20150328-039',
  213. '20150328-040','20150328-043',
  214. '20150328-047','20150328-048',
  215. '20150328-049','20150329-020',
  216. '20150329-112','20150513-002',
  217. '20150513-008','20150513-009',
  218. '20150513-010','20150513-011',
  219. '20150513-012','20150513-013',
  220. '20150513-018','20150514-002',
  221. '20150514-007','20150514-008',
  222. '20150514-009','20150514-010'
  223. )
  224. insert into [bak].[dbo].[mywork] select * from [db].[dbo].[mywork] where id in(
  225. '20150302-012','20150310-021',
  226. '20150312-029','20150327-022',
  227. '20150327-023','20150327-024',
  228. '20150328-034','20150328-035',
  229. '20150328-036','20150328-037',
  230. '20150328-038','20150328-039',
  231. '20150328-040','20150328-043',
  232. '20150328-047','20150328-048',
  233. '20150328-049','20150329-020',
  234. '20150329-112','20150513-002',
  235. '20150513-008','20150513-009',
  236. '20150513-010','20150513-011',
  237. '20150513-012','20150513-013',
  238. '20150513-018','20150514-002',
  239. '20150514-007','20150514-008',
  240. '20150514-009','20150514-010'
  241. )
  242. insert into [bak].[dbo].[photoprint] select * from [db].[dbo].[photoprint] where id in(
  243. '20150302-012','20150310-021',
  244. '20150312-029','20150327-022',
  245. '20150327-023','20150327-024',
  246. '20150328-034','20150328-035',
  247. '20150328-036','20150328-037',
  248. '20150328-038','20150328-039',
  249. '20150328-040','20150328-043',
  250. '20150328-047','20150328-048',
  251. '20150328-049','20150329-020',
  252. '20150329-112','20150513-002',
  253. '20150513-008','20150513-009',
  254. '20150513-010','20150513-011',
  255. '20150513-012','20150513-013',
  256. '20150513-018','20150514-002',
  257. '20150514-007','20150514-008',
  258. '20150514-009','20150514-010'
  259. )
  260. /*
  261. insert into [db].[dbo].[client] select * from [2013].[dbo].[client] where id = '20130725-008'
  262. insert into [db].[dbo].[dindan] select * from [2013].[dbo].[dindan] where id = '20130725-008'
  263. insert into [db].[dbo].[dindanjd] select * from [2013].[dbo].[dindanjd] where id = '20130725-008'
  264. insert into [db].[dbo].[dindansp]([id],[spid],[shuliang],[kind],[price]
  265. ,[name],[no],[status1],[status2],[status3]
  266. ,[status4],[date1],[date2],[date3],[date4],[name1]
  267. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  268. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  269. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] )
  270. select [id],[spid],[shuliang],[kind],[price]
  271. ,[name],[no],[status1],[status2],[status3]
  272. ,[status4],[date1],[date2],[date3],[date4],[name1]
  273. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  274. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  275. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] from [2013].[dbo].[dindansp] where id = '20130725-008'
  276. insert into [db].[dbo].[dindansp2] select * from [2013].[dbo].[dindansp2] where id = '20130725-008'
  277. insert into [db].[dbo].[dindansp3] select * from [2013].[dbo].[dindansp3] where id = '20130725-008'
  278. insert into [db].[dbo].[dindanbukuan]([id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck],[discount],[time])
  279. select [id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck],[discount],[time]
  280. from [2013].[dbo].[dindanbukuan] where id = '20130725-008'
  281. insert into [db].[dbo].[dindanbukuan2]([id],[money],[ren],[date],[bz],[kind],[ren2])
  282. select [id],[money],[ren],[date],[bz],[kind],[ren2]
  283. from [2013].[dbo].[dindanbukuan2] where id = '20130725-008'
  284. insert into [db].[dbo].[burncdreg] select * from [2013].[dbo].[burncdreg] where id = '20130725-008'
  285. insert into [db].[dbo].[digitalwork] select * from [2013].[dbo].[digitalwork] where id = '20130725-008'
  286. insert into [db].[dbo].[mywork] select * from [2013].[dbo].[mywork] where id = '20130725-008'
  287. insert into [db].[dbo].[photoprint] select * from [2013].[dbo].[photoprint] where id ='20130725-008'
  288. */