将2014的数据转回当前数据库.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. --将2014订单中的数据转回;
  2. --1.dindan;当乱序时,不能使用insert [db].[dindan] select * from [2014].[dindan]
  3. --insert into [db].[dbo].[dindan]
  4. insert [db].[dbo].[dindan]
  5. ([id]
  6. ,[money1]
  7. ,[money2]
  8. ,[money3]
  9. ,[name1]
  10. ,[name2]
  11. ,[taoxiid]
  12. ,[taoxiname]
  13. ,[taoxijiage]
  14. ,[taoxizs]
  15. ,[time1]
  16. ,[time2]
  17. ,[time3]
  18. ,[bm]
  19. ,[ren]
  20. ,[discount]
  21. ,[payed1]
  22. ,[payed2]
  23. ,[payed3]
  24. ,[payed4]
  25. ,[payed5]
  26. ,[time4]
  27. ,[time5]
  28. ,[takezs]
  29. ,[choosezs]
  30. ,[status]
  31. ,[clothescount2]
  32. ,[outside2]
  33. ,[style]
  34. ,[payed3time]
  35. ,[payed4ren]
  36. ,[payed4time]
  37. ,[status2]
  38. ,[status3]
  39. ,[waiter1]
  40. ,[waiter2]
  41. ,[waiter3]
  42. ,[waiter4]
  43. ,[bz]
  44. ,[taketime]
  45. ,[clothescount]
  46. ,[outside]
  47. ,[bz2]
  48. ,[bz3]
  49. ,[urgent]
  50. ,[status4]
  51. ,[status5]
  52. ,[waiter5]
  53. ,[waiter6]
  54. ,[pinyin1]
  55. ,[pinyin2]
  56. ,[waiter7]
  57. ,[status6]
  58. ,[phone1]
  59. ,[phone2]
  60. ,[status7]
  61. ,[memberno]
  62. ,[waiter8]
  63. ,[time6]
  64. ,[status8]
  65. ,[bruncount]
  66. ,[tichenren1]
  67. ,[tichenren2]
  68. ,[tichenren3]
  69. ,[tichenren4]
  70. ,[tichenren5]
  71. ,[send1]
  72. ,[send2]
  73. ,[send3]
  74. ,[datetime4]
  75. ,[datetime5]
  76. ,[datetime6]
  77. ,[waiter12]
  78. ,[waiter13]
  79. ,[waiter14]
  80. ,[waiter22]
  81. ,[waiter23]
  82. ,[waiter24]
  83. ,[waiter1rate]
  84. ,[waiter12rate]
  85. ,[waiter13rate]
  86. ,[waiter14rate]
  87. ,[waiter2rate]
  88. ,[waiter22rate]
  89. ,[waiter23rate]
  90. ,[waiter24rate]
  91. ,[ren2]
  92. ,[renrate]
  93. ,[ren2rate]
  94. ,[delphotos]
  95. ,[delphotos2]
  96. ,[txtype]
  97. ,[growthtxselname]
  98. ,[designno]
  99. ,[designreplaceno]
  100. ,[size]
  101. ,[dindantype]
  102. ,[contractno1]
  103. ,[contractno2]
  104. ,[cfno]
  105. ,[calldate]
  106. ,[from]
  107. ,[reason]
  108. ,[time7]
  109. ,[time8]
  110. ,[time9]
  111. ,[time10]
  112. ,[authorize]
  113. ,[discount2]
  114. ,[authorize2]
  115. ,[bz4]
  116. ,[satisfaction1]
  117. ,[satisfaction2]
  118. ,[satisfaction3]
  119. ,[satisfaction4]
  120. ,[satisfaction5]
  121. ,[satisfaction6]
  122. ,[satisfaction7]
  123. ,[bz5]
  124. ,[send4]
  125. ,[send5]
  126. ,[waiter9]
  127. ,[curno]
  128. ,[xplrr]
  129. ,[xplrtime]
  130. ,[satisfaction8]
  131. ,[VisitPeople1]
  132. ,[VisitPeople2]
  133. ,[VisitPeople3]
  134. ,[VisitPeople4]
  135. ,[VisitPeople5]
  136. ,[VisitPeople6]
  137. ,[VisitPeople7]
  138. ,[VisitPeople8]
  139. ,[VisitTime1]
  140. ,[VisitTime2]
  141. ,[VisitTime3]
  142. ,[VisitTime4]
  143. ,[VisitTime5]
  144. ,[VisitTime6]
  145. ,[VisitTime7]
  146. ,[VisitTime8])
  147. select [id]
  148. ,[money1]
  149. ,[money2]
  150. ,[money3]
  151. ,[name1]
  152. ,[name2]
  153. ,[taoxiid]
  154. ,[taoxiname]
  155. ,[taoxijiage]
  156. ,[taoxizs]
  157. ,[time1]
  158. ,[time2]
  159. ,[time3]
  160. ,[bm]
  161. ,[ren]
  162. ,[discount]
  163. ,[payed1]
  164. ,[payed2]
  165. ,[payed3]
  166. ,[payed4]
  167. ,[payed5]
  168. ,[time4]
  169. ,[time5]
  170. ,[takezs]
  171. ,[choosezs]
  172. ,[status]
  173. ,[clothescount2]
  174. ,[outside2]
  175. ,[style]
  176. ,[payed3time]
  177. ,[payed4ren]
  178. ,[payed4time]
  179. ,[status2]
  180. ,[status3]
  181. ,[waiter1]
  182. ,[waiter2]
  183. ,[waiter3]
  184. ,[waiter4]
  185. ,[bz]
  186. ,[taketime]
  187. ,[clothescount]
  188. ,[outside]
  189. ,[bz2]
  190. ,[bz3]
  191. ,[urgent]
  192. ,[status4]
  193. ,[status5]
  194. ,[waiter5]
  195. ,[waiter6]
  196. ,[pinyin1]
  197. ,[pinyin2]
  198. ,[waiter7]
  199. ,[status6]
  200. ,[phone1]
  201. ,[phone2]
  202. ,[status7]
  203. ,[memberno]
  204. ,[waiter8]
  205. ,[time6]
  206. ,[status8]
  207. ,[bruncount]
  208. ,[tichenren1]
  209. ,[tichenren2]
  210. ,[tichenren3]
  211. ,[tichenren4]
  212. ,[tichenren5]
  213. ,[send1]
  214. ,[send2]
  215. ,[send3]
  216. ,[datetime4]
  217. ,[datetime5]
  218. ,[datetime6]
  219. ,[waiter12]
  220. ,[waiter13]
  221. ,[waiter14]
  222. ,[waiter22]
  223. ,[waiter23]
  224. ,[waiter24]
  225. ,[waiter1rate]
  226. ,[waiter12rate]
  227. ,[waiter13rate]
  228. ,[waiter14rate]
  229. ,[waiter2rate]
  230. ,[waiter22rate]
  231. ,[waiter23rate]
  232. ,[waiter24rate]
  233. ,[ren2]
  234. ,[renrate]
  235. ,[ren2rate]
  236. ,[delphotos]
  237. ,[delphotos2]
  238. ,[txtype]
  239. ,[growthtxselname]
  240. ,[designno]
  241. ,[designreplaceno]
  242. ,[size]
  243. ,[dindantype]
  244. ,[contractno1]
  245. ,[contractno2]
  246. ,[cfno]
  247. ,[calldate]
  248. ,[from]
  249. ,[reason]
  250. ,[time7]
  251. ,[time8]
  252. ,[time9]
  253. ,[time10]
  254. ,[authorize]
  255. ,[discount2]
  256. ,[authorize2]
  257. ,[bz4]
  258. ,[satisfaction1]
  259. ,[satisfaction2]
  260. ,[satisfaction3]
  261. ,[satisfaction4]
  262. ,[satisfaction5]
  263. ,[satisfaction6]
  264. ,[satisfaction7]
  265. ,[bz5]
  266. ,[send4]
  267. ,[send5]
  268. ,[waiter9]
  269. ,[curno]
  270. ,[xplrr]
  271. ,[xplrtime]
  272. ,[satisfaction8]
  273. ,[VisitPeople1]
  274. ,[VisitPeople2]
  275. ,[VisitPeople3]
  276. ,[VisitPeople4]
  277. ,[VisitPeople5]
  278. ,[VisitPeople6]
  279. ,[VisitPeople7]
  280. ,[VisitPeople8]
  281. ,[VisitTime1]
  282. ,[VisitTime2]
  283. ,[VisitTime3]
  284. ,[VisitTime4]
  285. ,[VisitTime5]
  286. ,[VisitTime6]
  287. ,[VisitTime7]
  288. ,[VisitTime8]
  289. from [2014].[dbo].[dindan]
  290. where [2014].[dbo].[dindan].[id] not in(select id from [db].[dbo].[dindan])
  291. go
  292. --2.dindansp
  293. set IDENTITY_INSERT [db].[dbo].[dindansp] ON
  294. insert into [db].[dbo].[dindansp]
  295. ([id]
  296. ,[spid]
  297. ,[shuliang]
  298. ,[kind]
  299. ,[price]
  300. ,[name]
  301. ,[no]
  302. ,[status1]
  303. ,[status2]
  304. ,[status3]
  305. ,[status4]
  306. ,[autoid]
  307. ,[date1]
  308. ,[date2]
  309. ,[date3]
  310. ,[date4]
  311. ,[name1]
  312. ,[name2]
  313. ,[name3]
  314. ,[name4]
  315. ,[hqdate]
  316. ,[hqtime]
  317. ,[urgent]
  318. ,[taketime]
  319. ,[no2]
  320. ,[status5]
  321. ,[status6]
  322. ,[date5]
  323. ,[date6]
  324. ,[name5]
  325. ,[name6]
  326. ,[growthtxname]
  327. ,[ps]
  328. ,[zs]
  329. ,[ren1]
  330. ,[ren2]
  331. ,[hqstatus]
  332. ,[bz])
  333. select * from [2014].[dbo].[dindansp] where not exists(select id from [db].[dbo].[dindansp] where [db].[dbo].[dindansp].[id] = [2014].[dbo].[dindansp].[id])
  334. SET IDENTITY_INSERT [db].[dbo].[dindansp] OFF
  335. go
  336. --3.dindanbukuan表;
  337. --set IDENTITY_INSERT [db].[dbo].[dindanbukuan] ON
  338. insert into [db].[dbo].[dindanbukuan] ([id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck]) select [id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck] from [2014].[dbo].[dindanbukuan]
  339. where not exists(select id from [db].[dbo].[dindanbukuan] where [db].[dbo].[dindanbukuan].[id] = [2014].[dbo].[dindanbukuan].[id])
  340. --SET IDENTITY_INSERT [db].[dbo].[dindanbukuan] OFF
  341. go
  342. --4.dindanbukuan2表;
  343. --set IDENTITY_INSERT [db].[dbo].[dindanbukuan2] ON
  344. insert into [db].[dbo].[dindanbukuan2] ([id],[money],[ren],[date],[bz],[kind],[ren2]) select [id],[money],[ren],[date],[bz],[kind],[ren2] from [2014].[dbo].[dindanbukuan2]
  345. where not exists(select id from [db].[dbo].[dindanbukuan2] where [db].[dbo].[dindanbukuan2].[id] = [2014].[dbo].[dindanbukuan2].[id])
  346. --SET IDENTITY_INSERT [db].[dbo].[dindanbukuan2] OFF
  347. go
  348. --5.photoprint表;
  349. --insert into [db].[dbo].[photoprint] select * from [2014].[dbo].[photoprint]
  350. --where not exists(select id from [db].[dbo].[photoprint] where [db].[dbo].[photoprint].[id] = [2014].[dbo].[photoprint].[id])
  351. --6.client表;
  352. insert into [db].[dbo].[client] select * from [2014].[dbo].[client]
  353. where not exists(select id from [db].[dbo].[client] where [db].[dbo].[client].[id] = [2014].[dbo].[client].[id])
  354. --where id not in(select id from [db].[dbo].[client] where [db].[dbo].[client].[id] = [2014].[dbo].[client].[id])
  355. go
  356. --7.burncdreg表;
  357. insert into [db].[dbo].[burncdreg] select * from [2014].[dbo].[burncdreg]
  358. where not exists(select id from [db].[dbo].[burncdreg] where [db].[dbo].[burncdreg].[id] = [2014].[dbo].[burncdreg].[id])
  359. go
  360. --8.digitalwork表;
  361. insert into [db].[dbo].[digitalwork] select * from [2014].[dbo].[digitalwork]
  362. where not exists(select id from [db].[dbo].[digitalwork] where [db].[dbo].[digitalwork].[id] = [2014].[dbo].[digitalwork].[id])
  363. go
  364. --9.mywork;
  365. insert into [db].[dbo].[mywork] select * from [2014].[dbo].[mywork]
  366. where not exists(select id from [db].[dbo].[mywork] where [db].[dbo].[mywork].[id] = [2014].[dbo].[mywork].[id])
  367. go
  368. --10.dindanjd表;
  369. insert into [db].[dbo].[dindanjd] select * from [2014].[dbo].[dindanjd]
  370. where not exists(select id from [db].[dbo].[dindanjd] where [db].[dbo].[dindanjd].[id] = [2014].[dbo].[dindanjd].[id])
  371. go
  372. --11.dindansp2表;
  373. insert into [db].[dbo].[dindansp2] select * from [2014].[dbo].[dindansp2]
  374. where not exists(select id from [db].[dbo].[dindansp2] where [db].[dbo].[dindansp2].[id] = [2014].[dbo].[dindansp2].[id])
  375. go
  376. --12.dindansp3表;
  377. insert into [db].[dbo].[dindansp3] select * from [2014].[dbo].[dindansp3]
  378. where not exists(select id from [db].[dbo].[dindansp3] where [db].[dbo].[dindansp3].[id] = [2014].[dbo].[dindansp3].[id])
  379. go
  380. --13.[gudingfeiyong]
  381. set IDENTITY_INSERT [db].[dbo].[gudingfeiyong] ON
  382. INSERT INTO [db].[dbo].[gudingfeiyong]
  383. ([id]
  384. ,[name]
  385. ,[money]
  386. ,[dat]
  387. ,[bz]
  388. ,[renyuan1]
  389. ,[renyuan2]
  390. ,[financecheck]
  391. ,[time]
  392. ,[photo]
  393. ,[financecheck2]
  394. ,[financecheck3]
  395. ,[hasphoto]) select * from [2014].[dbo].[gudingfeiyong]
  396. where not exists(select id from [db].[dbo].[gudingfeiyong] where [db].[dbo].[gudingfeiyong].[id] = [2014].[dbo].[gudingfeiyong].[id])
  397. set IDENTITY_INSERT [db].[dbo].[gudingfeiyong] OFF
  398. go
  399. --14.[singleincome]
  400. set IDENTITY_INSERT [db].[dbo].[singleincome] ON
  401. insert into [db].[dbo].[singleincome]
  402. ([id]
  403. ,[name]
  404. ,[money]
  405. ,[dat]
  406. ,[bz]
  407. ,[renyuan1]
  408. ,[renyuan2]
  409. ,[renyuan3]
  410. ,[sale2type]
  411. ,[paytype]
  412. ,[phone]
  413. ,[payed]
  414. ,[balance]
  415. ,[pinyin]
  416. ,[financecheck]
  417. ,[count]
  418. ,[time]) select * from [2014].[dbo].[singleincome]
  419. where not exists(select id from [db].[dbo].[singleincome] where [db].[dbo].[singleincome].[id] = [2014].[dbo].[singleincome].[id])
  420. set IDENTITY_INSERT [db].[dbo].[singleincome] OFF
  421. go
  422. --15.[singleincomemoney]
  423. set IDENTITY_INSERT [db].[dbo].[singleincomemoney] ON
  424. insert into [db].[dbo].[singleincomemoney]
  425. ([id]
  426. ,[money]
  427. ,[date]
  428. ,[clerk]
  429. ,[paytype]
  430. ,[autoid]
  431. ,[financecheck]
  432. ,[time]
  433. ,[jdd]) select * from [2014].[dbo].[singleincomemoney]
  434. where not exists(select id from [db].[dbo].[singleincomemoney] where [db].[dbo].[singleincomemoney].[id] = [2014].[dbo].[singleincomemoney].[id])
  435. set IDENTITY_INSERT [db].[dbo].[singleincomemoney] OFF
  436. go