Convert2014ToCurrentCatalog.sql 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. --将2014订单中的数据转回;
  2. --1.dindan;
  3. insert [db].[dbo].[dindan]
  4. ([id]
  5. ,[money1]
  6. ,[money2]
  7. ,[money3]
  8. ,[name1]
  9. ,[name2]
  10. ,[taoxiid]
  11. ,[taoxiname]
  12. ,[taoxijiage]
  13. ,[taoxizs]
  14. ,[time1]
  15. ,[time2]
  16. ,[time3]
  17. ,[bm]
  18. ,[ren]
  19. ,[discount]
  20. ,[payed1]
  21. ,[payed2]
  22. ,[payed3]
  23. ,[payed4]
  24. ,[payed5]
  25. ,[time4]
  26. ,[time5]
  27. ,[takezs]
  28. ,[choosezs]
  29. ,[status]
  30. ,[clothescount2]
  31. ,[outside2]
  32. ,[style]
  33. ,[payed3time]
  34. ,[payed4ren]
  35. ,[payed4time]
  36. ,[status2]
  37. ,[status3]
  38. ,[waiter1]
  39. ,[waiter2]
  40. ,[waiter3]
  41. ,[waiter4]
  42. ,[bz]
  43. ,[taketime]
  44. ,[clothescount]
  45. ,[outside]
  46. ,[bz2]
  47. ,[bz3]
  48. ,[urgent]
  49. ,[status4]
  50. ,[status5]
  51. ,[waiter5]
  52. ,[waiter6]
  53. ,[pinyin1]
  54. ,[pinyin2]
  55. ,[waiter7]
  56. ,[status6]
  57. ,[phone1]
  58. ,[phone2]
  59. ,[status7]
  60. ,[memberno]
  61. ,[waiter8]
  62. ,[time6]
  63. ,[status8]
  64. ,[bruncount]
  65. ,[tichenren1]
  66. ,[tichenren2]
  67. ,[tichenren3]
  68. ,[tichenren4]
  69. ,[tichenren5]
  70. ,[send1]
  71. ,[send2]
  72. ,[send3]
  73. ,[datetime4]
  74. ,[datetime5]
  75. ,[datetime6]
  76. ,[waiter12]
  77. ,[waiter13]
  78. ,[waiter14]
  79. ,[waiter22]
  80. ,[waiter23]
  81. ,[waiter24]
  82. ,[waiter1rate]
  83. ,[waiter12rate]
  84. ,[waiter13rate]
  85. ,[waiter14rate]
  86. ,[waiter2rate]
  87. ,[waiter22rate]
  88. ,[waiter23rate]
  89. ,[waiter24rate]
  90. ,[ren2]
  91. ,[renrate]
  92. ,[ren2rate]
  93. ,[delphotos]
  94. ,[delphotos2]
  95. ,[txtype]
  96. ,[growthtxselname]
  97. ,[designno]
  98. ,[designreplaceno]
  99. ,[size]
  100. ,[dindantype]
  101. ,[contractno1]
  102. ,[contractno2]
  103. ,[cfno]
  104. ,[calldate]
  105. ,[from]
  106. ,[reason]
  107. ,[time7]
  108. ,[time8]
  109. ,[time9]
  110. ,[time10]
  111. ,[authorize]
  112. ,[discount2]
  113. ,[authorize2]
  114. ,[bz4]
  115. ,[satisfaction1]
  116. ,[satisfaction2]
  117. ,[satisfaction3]
  118. ,[satisfaction4]
  119. ,[satisfaction5]
  120. ,[satisfaction6]
  121. ,[satisfaction7]
  122. ,[bz5]
  123. ,[send4]
  124. ,[send5]
  125. ,[waiter9]
  126. ,[curno]
  127. ,[xplrr]
  128. ,[xplrtime]
  129. ,[satisfaction8]
  130. ,[VisitPeople1]
  131. ,[VisitPeople2]
  132. ,[VisitPeople3]
  133. ,[VisitPeople4]
  134. ,[VisitPeople5]
  135. ,[VisitPeople6]
  136. ,[VisitPeople7]
  137. ,[VisitPeople8]
  138. ,[VisitTime1]
  139. ,[VisitTime2]
  140. ,[VisitTime3]
  141. ,[VisitTime4]
  142. ,[VisitTime5]
  143. ,[VisitTime6]
  144. ,[VisitTime7]
  145. ,[VisitTime8])
  146. select [id]
  147. ,[money1]
  148. ,[money2]
  149. ,[money3]
  150. ,[name1]
  151. ,[name2]
  152. ,[taoxiid]
  153. ,[taoxiname]
  154. ,[taoxijiage]
  155. ,[taoxizs]
  156. ,[time1]
  157. ,[time2]
  158. ,[time3]
  159. ,[bm]
  160. ,[ren]
  161. ,[discount]
  162. ,[payed1]
  163. ,[payed2]
  164. ,[payed3]
  165. ,[payed4]
  166. ,[payed5]
  167. ,[time4]
  168. ,[time5]
  169. ,[takezs]
  170. ,[choosezs]
  171. ,[status]
  172. ,[clothescount2]
  173. ,[outside2]
  174. ,[style]
  175. ,[payed3time]
  176. ,[payed4ren]
  177. ,[payed4time]
  178. ,[status2]
  179. ,[status3]
  180. ,[waiter1]
  181. ,[waiter2]
  182. ,[waiter3]
  183. ,[waiter4]
  184. ,[bz]
  185. ,[taketime]
  186. ,[clothescount]
  187. ,[outside]
  188. ,[bz2]
  189. ,[bz3]
  190. ,[urgent]
  191. ,[status4]
  192. ,[status5]
  193. ,[waiter5]
  194. ,[waiter6]
  195. ,[pinyin1]
  196. ,[pinyin2]
  197. ,[waiter7]
  198. ,[status6]
  199. ,[phone1]
  200. ,[phone2]
  201. ,[status7]
  202. ,[memberno]
  203. ,[waiter8]
  204. ,[time6]
  205. ,[status8]
  206. ,[bruncount]
  207. ,[tichenren1]
  208. ,[tichenren2]
  209. ,[tichenren3]
  210. ,[tichenren4]
  211. ,[tichenren5]
  212. ,[send1]
  213. ,[send2]
  214. ,[send3]
  215. ,[datetime4]
  216. ,[datetime5]
  217. ,[datetime6]
  218. ,[waiter12]
  219. ,[waiter13]
  220. ,[waiter14]
  221. ,[waiter22]
  222. ,[waiter23]
  223. ,[waiter24]
  224. ,[waiter1rate]
  225. ,[waiter12rate]
  226. ,[waiter13rate]
  227. ,[waiter14rate]
  228. ,[waiter2rate]
  229. ,[waiter22rate]
  230. ,[waiter23rate]
  231. ,[waiter24rate]
  232. ,[ren2]
  233. ,[renrate]
  234. ,[ren2rate]
  235. ,[delphotos]
  236. ,[delphotos2]
  237. ,[txtype]
  238. ,[growthtxselname]
  239. ,[designno]
  240. ,[designreplaceno]
  241. ,[size]
  242. ,[dindantype]
  243. ,[contractno1]
  244. ,[contractno2]
  245. ,[cfno]
  246. ,[calldate]
  247. ,[from]
  248. ,[reason]
  249. ,[time7]
  250. ,[time8]
  251. ,[time9]
  252. ,[time10]
  253. ,[authorize]
  254. ,[discount2]
  255. ,[authorize2]
  256. ,[bz4]
  257. ,[satisfaction1]
  258. ,[satisfaction2]
  259. ,[satisfaction3]
  260. ,[satisfaction4]
  261. ,[satisfaction5]
  262. ,[satisfaction6]
  263. ,[satisfaction7]
  264. ,[bz5]
  265. ,[send4]
  266. ,[send5]
  267. ,[waiter9]
  268. ,[curno]
  269. ,[xplrr]
  270. ,[xplrtime]
  271. ,[satisfaction8]
  272. ,[VisitPeople1]
  273. ,[VisitPeople2]
  274. ,[VisitPeople3]
  275. ,[VisitPeople4]
  276. ,[VisitPeople5]
  277. ,[VisitPeople6]
  278. ,[VisitPeople7]
  279. ,[VisitPeople8]
  280. ,[VisitTime1]
  281. ,[VisitTime2]
  282. ,[VisitTime3]
  283. ,[VisitTime4]
  284. ,[VisitTime5]
  285. ,[VisitTime6]
  286. ,[VisitTime7]
  287. ,[VisitTime8]
  288. from [2014].[dbo].[dindan]
  289. where [2014].[dbo].[dindan].[id] not in(select id from [db].[dbo].[dindan])
  290. go
  291. --2.dindansp
  292. --drop table [db].[dbo].[dindansp#]
  293. select [id],[spid],[shuliang],[kind],[price]
  294. ,[name],[no],[status1],[status2],[status3]
  295. ,[status4],[date1],[date2],[date3],[date4],[name1]
  296. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  297. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  298. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz]
  299. into [db].[dbo].[dindansp#] from [db].[dbo].[dindansp]
  300. go
  301. insert into [db].[dbo].[dindansp#]
  302. select [id],[spid],[shuliang],[kind],[price]
  303. ,[name],[no],[status1],[status2],[status3]
  304. ,[status4],[date1],[date2],[date3],[date4],[name1]
  305. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  306. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  307. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz]
  308. from [2014].[dbo].[dindansp]
  309. go
  310. select distinct * into #temp from [db].[dbo].[dindansp#]
  311. go
  312. drop table [db].[dbo].[dindansp#]
  313. go
  314. drop table [db].[dbo].[dindansp]
  315. GO
  316. use [db]
  317. CREATE TABLE [dbo].[dindansp](
  318. [id] [nvarchar](50) NULL,
  319. [spid] [nvarchar](50) NULL,
  320. [shuliang] [nvarchar](120) NULL,
  321. [kind] [nvarchar](10) NULL,
  322. [price] [nvarchar](50) NULL,
  323. [name] [nvarchar](50) NULL,
  324. [no] [nvarchar](max) NULL,
  325. [status1] [nvarchar](50) NULL,
  326. [status2] [nvarchar](50) NULL,
  327. [status3] [nvarchar](50) NULL,
  328. [status4] [nvarchar](50) NULL,
  329. [autoid] [int] IDENTITY(1,1) NOT NULL,
  330. [date1] [nvarchar](50) NULL,
  331. [date2] [nvarchar](50) NULL,
  332. [date3] [nvarchar](50) NULL,
  333. [date4] [nvarchar](50) NULL,
  334. [name1] [nvarchar](50) NULL,
  335. [name2] [nvarchar](50) NULL,
  336. [name3] [nvarchar](50) NULL,
  337. [name4] [nvarchar](50) NULL,
  338. [hqdate] [nvarchar](50) NULL,
  339. [hqtime] [nvarchar](50) NULL,
  340. [urgent] [nvarchar](50) NULL,
  341. [taketime] [nvarchar](50) NULL,
  342. [no2] [nvarchar](max) NULL,
  343. [growthtxname] [nvarchar](50) NULL,
  344. [status5] [nvarchar](50) NULL,
  345. [status6] [nvarchar](50) NULL,
  346. [date5] [nvarchar](50) NULL,
  347. [date6] [nvarchar](50) NULL,
  348. [name5] [nvarchar](50) NULL,
  349. [name6] [nvarchar](50) NULL,
  350. [ps] [nvarchar](50) NULL,
  351. [zs] [nvarchar](50) NULL,
  352. [ren1] [nvarchar](120) NULL,
  353. [ren2] [nvarchar](120) NULL,
  354. [hqstatus] [nvarchar](50) NULL,
  355. [bz] [nvarchar](200) NULL
  356. ) ON [PRIMARY]
  357. GO
  358. go
  359. insert into dindansp([id],[spid],[shuliang],[kind],[price]
  360. ,[name],[no],[status1],[status2],[status3]
  361. ,[status4],[date1],[date2],[date3],[date4],[name1]
  362. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  363. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  364. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] ) select [id],[spid],[shuliang],[kind],[price]
  365. ,[name],[no],[status1],[status2],[status3]
  366. ,[status4],[date1],[date2],[date3],[date4],[name1]
  367. ,[name2],[name3],[name4],[hqdate],[hqtime],[urgent]
  368. ,[taketime],[no2],[status5],[status6],[date5],[date6],[name5]
  369. ,[name6],[growthtxname],[ps],[zs],[ren1],[ren2],[hqstatus],[bz] from #temp
  370. go
  371. drop table #temp
  372. go
  373. --3.dindanbukuan表;
  374. go
  375. select [id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck]
  376. into [db].[dbo].[dindanbukuan#]
  377. from [db].[dbo].[dindanbukuan]
  378. go
  379. insert into [db].[dbo].[dindanbukuan#]
  380. select [id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck]
  381. from [2014].[dbo].[dindanbukuan]
  382. go
  383. use db
  384. go
  385. select distinct * into #temp from [db].[dbo].[dindanbukuan#]
  386. go
  387. drop table dindanbukuan#
  388. go
  389. drop table dindanbukuan
  390. go
  391. GO
  392. use [db]
  393. CREATE TABLE [dbo].[dindanbukuan](
  394. [autoid] [int] IDENTITY(1,1) NOT NULL,
  395. [id] [nvarchar](50) NULL,
  396. [money] [nvarchar](50) NULL,
  397. [ren] [nvarchar](50) NULL,
  398. [date] [nvarchar](50) NULL,
  399. [bz] [nvarchar](max) NULL,
  400. [kind] [nvarchar](50) NULL,
  401. [ren2] [nvarchar](50) NULL,
  402. [item] [nvarchar](max) NULL,
  403. [paytype] [nvarchar](50) NULL,
  404. [jdd] [nvarchar](50) NULL,
  405. [financecheck] [nvarchar](10) NULL,
  406. [discount] [nvarchar](50) NULL,
  407. [time] [nvarchar](50) NULL
  408. ) ON [PRIMARY]
  409. GO
  410. go
  411. 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 #temp
  412. go
  413. drop table #temp
  414. go
  415. --4.dindanbukuan2表;
  416. select [id],[money],[ren],[date],[bz],[kind],[ren2] into [db].[dbo].[dindanbukuan2#]
  417. from [db].[dbo].[dindanbukuan2]
  418. insert into [db].[dbo].[dindanbukuan2#]
  419. select [id],[money],[ren],[date],[bz],[kind],[ren2]
  420. from [2014].[dbo].[dindanbukuan2]
  421. go
  422. select distinct * into #temp from dindanbukuan2#
  423. go
  424. drop table dindanbukuan2#
  425. drop table dindanbukuan2
  426. GO
  427. use [db]
  428. CREATE TABLE [dbo].[dindanbukuan2](
  429. [autoid] [int] IDENTITY(1,1) NOT NULL,
  430. [id] [nvarchar](50) NULL,
  431. [money] [nvarchar](50) NULL,
  432. [ren] [nvarchar](50) NULL,
  433. [date] [nvarchar](50) NULL,
  434. [bz] [nvarchar](500) NULL,
  435. [kind] [nvarchar](50) NULL,
  436. [ren2] [nvarchar](50) NULL
  437. ) ON [PRIMARY]
  438. GO
  439. go
  440. insert into [db].[dbo].[dindanbukuan2]([id],[money],[ren],[date],[bz],[kind],[ren2]) select [id],[money],[ren],[date],[bz],[kind],[ren2] from #temp
  441. go
  442. drop table #temp
  443. go
  444. --5.photoprint表;
  445. --insert into [db].[dbo].[photoprint] select * from [2014].[dbo].[photoprint]
  446. --where not exists(select id from [db].[dbo].[photoprint] where [db].[dbo].[photoprint].[id] = [2014].[dbo].[photoprint].[id])
  447. --6.client表;
  448. insert into [db].[dbo].[client] select * from [2014].[dbo].[client]
  449. where not exists(select id from [db].[dbo].[client] where [db].[dbo].[client].[id] = [2014].[dbo].[client].[id])
  450. --7.burncdreg表;
  451. insert into [db].[dbo].[burncdreg] select * from [2014].[dbo].[burncdreg]
  452. where not exists(select id from [db].[dbo].[burncdreg] where [db].[dbo].[burncdreg].[id] = [2014].[dbo].[burncdreg].[id])
  453. --8.digitalwork表;
  454. insert into [db].[dbo].[digitalwork] select * from [2014].[dbo].[digitalwork]
  455. where not exists(select id from [db].[dbo].[digitalwork] where [db].[dbo].[digitalwork].[id] = [2014].[dbo].[digitalwork].[id])
  456. --9.mywork;
  457. insert into [db].[dbo].[mywork] select * from [2014].[dbo].[mywork]
  458. where not exists(select id from [db].[dbo].[mywork] where [db].[dbo].[mywork].[id] = [2014].[dbo].[mywork].[id])
  459. --10.dindanjd表;
  460. select * into [db].[dbo].[dindanjd#] from [2014].[dbo].[dindanjd]
  461. insert into [db].[dbo].[dindanjd#] select * from [db].[dbo].[dindanjd]
  462. go
  463. select distinct * into #temp from dindanjd#
  464. go
  465. drop table dindanjd#
  466. drop table dindanjd
  467. GO
  468. use [db]
  469. CREATE TABLE [dbo].[dindanjd](
  470. [id] [nvarchar](50) NULL,
  471. [name] [nvarchar](50) NULL,
  472. [date] [nvarchar](50) NULL,
  473. [time] [nvarchar](50) NULL,
  474. [waiter1] [nvarchar](50) NULL,
  475. [waiter2] [nvarchar](50) NULL,
  476. [status] [nvarchar](50) NULL,
  477. [waiter12] [nvarchar](50) NULL,
  478. [waiter22] [nvarchar](50) NULL,
  479. [bookingdate] [nvarchar](50) NULL,
  480. [dress] [nvarchar](150) NULL,
  481. [bz] [nvarchar](150) NULL,
  482. [clerk] [nvarchar](120) NULL,
  483. [inputtime] [nvarchar](50) NULL,
  484. [branch] [nvarchar](50) NULL
  485. ) ON [PRIMARY]
  486. GO
  487. go
  488. insert into dindanjd select * from #temp
  489. go
  490. drop table #temp
  491. go
  492. --11.dindansp2表;
  493. select * into [db].[dbo].[dindansp2#] from [db].[dbo].[dindansp2]
  494. insert into [db].[dbo].[dindansp2#] select * from [2014].[dbo].[dindansp2]
  495. go
  496. select distinct * into #temp from dindansp2#
  497. go
  498. drop table dindansp2#
  499. drop table dindansp2
  500. GO
  501. use [db]
  502. CREATE TABLE [dbo].[dindansp2](
  503. [id] [nvarchar](50) NULL,
  504. [name] [nvarchar](50) NULL,
  505. [count] [nvarchar](50) NULL,
  506. [date] [nvarchar](50) NULL,
  507. [clerk] [nvarchar](50) NULL
  508. ) ON [PRIMARY]
  509. GO
  510. go
  511. insert into dindansp2 select * from #temp
  512. go
  513. drop table #temp
  514. go
  515. --12.dindansp3表;
  516. select * into [db].[dbo].[dindansp3#] from [db].[dbo].[dindansp3]
  517. insert into [db].[dbo].[dindansp3#] select * from [2014].[dbo].[dindansp3]
  518. go
  519. select distinct * into #temp from dindansp3#
  520. go
  521. drop table dindansp3#
  522. drop table dindansp3
  523. GO
  524. use [db]
  525. CREATE TABLE [dbo].[dindansp3](
  526. [id] [nvarchar](50) NULL,
  527. [spid] [nvarchar](50) NULL,
  528. [name] [nvarchar](50) NULL,
  529. [count] [nvarchar](50) NULL
  530. ) ON [PRIMARY]
  531. GO
  532. go
  533. insert into dindansp3 select * from #temp
  534. go
  535. drop table #temp
  536. go
  537. --13.[gudingfeiyong]
  538. set IDENTITY_INSERT [db].[dbo].[gudingfeiyong] ON
  539. INSERT INTO [db].[dbo].[gudingfeiyong]
  540. ([id]
  541. ,[name]
  542. ,[money]
  543. ,[dat]
  544. ,[bz]
  545. ,[renyuan1]
  546. ,[renyuan2]
  547. ,[financecheck]
  548. ,[time]
  549. ,[photo]
  550. ,[financecheck2]
  551. ,[financecheck3]
  552. ,[hasphoto]) select * from [2014].[dbo].[gudingfeiyong]
  553. where not exists(select id from [db].[dbo].[gudingfeiyong] where [db].[dbo].[gudingfeiyong].[id] = [2014].[dbo].[gudingfeiyong].[id])
  554. set IDENTITY_INSERT [db].[dbo].[gudingfeiyong] OFF
  555. --14.[singleincome]
  556. set IDENTITY_INSERT [db].[dbo].[singleincome] ON
  557. insert into [db].[dbo].[singleincome]
  558. ([id]
  559. ,[name]
  560. ,[money]
  561. ,[dat]
  562. ,[bz]
  563. ,[renyuan1]
  564. ,[renyuan2]
  565. ,[renyuan3]
  566. ,[sale2type]
  567. ,[paytype]
  568. ,[phone]
  569. ,[payed]
  570. ,[balance]
  571. ,[pinyin]
  572. ,[financecheck]
  573. ,[count]
  574. ,[time]) select * from [2014].[dbo].[singleincome]
  575. where not exists(select id from [db].[dbo].[singleincome] where [db].[dbo].[singleincome].[id] = [2014].[dbo].[singleincome].[id])
  576. set IDENTITY_INSERT [db].[dbo].[singleincome] OFF
  577. --15.[singleincomemoney]
  578. set IDENTITY_INSERT [db].[dbo].[singleincomemoney] ON
  579. insert into [db].[dbo].[singleincomemoney]
  580. ([id]
  581. ,[money]
  582. ,[date]
  583. ,[clerk]
  584. ,[paytype]
  585. ,[autoid]
  586. ,[financecheck]
  587. ,[time]
  588. ,[jdd]) select * from [2014].[dbo].[singleincomemoney]
  589. where not exists(select id from [db].[dbo].[singleincomemoney] where [db].[dbo].[singleincomemoney].[id] = [2014].[dbo].[singleincomemoney].[id])
  590. set IDENTITY_INSERT [db].[dbo].[singleincomemoney] OFF