Steps to migrate data from access to Postgres
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Part Insert.sql 4.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. select 'insert into "PartNumber"("partNumber1", "description", "comments", "primaryCustomerPartNumber", "primaryVendorPartNumber", "secondaryVendorPartNumber"'
  2. + ', "ppap", "file", "stdCost", "listPrice", "createDate", "createUserId", "updateDate", "updateUserId", "partCodeId", "statusId"'
  3. + ', "primaryCustomerId", "primaryVendorId", "secondaryVendorId", "pickingLocationId", "packingLocationId", "replacedById", "replacesId"'
  4. + ', "weight") values('
  5. + ''''
  6. + a.partNumber1
  7. +''''
  8. + case
  9. when a.description IS NULL
  10. then ', null'
  11. else
  12. ', ' + ''''
  13. +a.description
  14. + ''''
  15. end
  16. + case
  17. when a.comments IS NULL
  18. then ', null'
  19. else
  20. ', ' + ''''
  21. +a.comments
  22. + ''''
  23. end
  24. + case
  25. when a.primaryCustomerPartNumber IS NULL
  26. then ', null'
  27. else
  28. ', ' + ''''
  29. +a.primaryCustomerPartNumber
  30. + ''''
  31. end
  32. + case
  33. when a.primaryVendorPartNumber IS NULL
  34. then ', null'
  35. else
  36. ', ' + ''''
  37. +a.primaryVendorPartNumber
  38. + ''''
  39. end
  40. + case
  41. when a.secondaryVendorPartNumber IS NULL
  42. then ', null'
  43. else
  44. ', ' + ''''
  45. +a.secondaryVendorPartNumber
  46. + ''''
  47. end
  48. + ', '
  49. + case when a.ppap = 1 then 'true' else 'false' end
  50. + case
  51. when a.[file] IS NULL
  52. then ', null'
  53. else
  54. ', ' + ''''
  55. +a.[file]
  56. + ''''
  57. end
  58. + case
  59. when a.stdCost IS NULL
  60. then ', null'
  61. else
  62. ', ' + ''''
  63. +a.stdCost
  64. + ''''
  65. end
  66. + case
  67. when a.listPrice IS NULL
  68. then ', null'
  69. else
  70. ', ' + ''''
  71. +a.listPrice
  72. + ''''
  73. end
  74. + case when a.createDate IS null then ', null'
  75. else
  76. ', ' + ''''
  77. + cast(a.createDate as varchar(max))
  78. + ''''
  79. end
  80. +', '
  81. + cast(a.createUserId as varchar(max))
  82. + case when a.updateDate is null then ', null'
  83. else
  84. ', ' + ''''
  85. + CAST(a.updateDate as varchar(max))
  86. + ''''
  87. end
  88. + ', '
  89. + cast(a.updateUserId as varchar(max))
  90. + ', ' + cast(a.partCodeId as varchar(max))
  91. + ', ' + cast(a.statusId as varchar(max))
  92. + ', ' + case when a.primaryCustomerId is null then 'null' else cast(a.primaryCustomerId as varchar(max)) end
  93. + ', ' + case when a.primaryVendorId is null then 'null' else cast(a.primaryVendorId as varchar(max)) end
  94. + ', ' + case when a.secondaryVendorId is null then 'null' else cast(a.secondaryVendorId as varchar(max)) end
  95. + ', ' + case when a.pickingLocationId is null then 'null' else cast(a.pickingLocationId as varchar(max)) end
  96. + ', ' + case when a.packingLocationId is null then 'null' else cast(a.packingLocationId as varchar(max)) end
  97. + ', ' + case when a.replacedById is null then 'null' else cast(a.replacedById as varchar(max)) end
  98. + ', ' + case when a.replacesId is null then 'null' else cast(a.replacesId as varchar(max)) end
  99. + ', ' + case when a.weight is null then 'null' else '''' + a.weight + '''' end
  100. + ');'
  101. from
  102. (
  103. select
  104. [RPM Part Number] as partNumber1,
  105. case when LEN([Part Description]) = 0 then null else replace([Part Description] , '''', '') end as description,
  106. case when LEN(Comments) = 0 then null else replace(Comments, '''', '')end as comments,
  107. case when LEN([Customer Part Number]) = 0 then null else replace([Customer Part Number], '''', '') end as primaryCustomerPartNumber,
  108. case when len([Primary Vendor Part #]) = 0 then null else REPLACE([Primary Vendor Part #], '''', '') end as primaryVendorPartNumber,
  109. case when len([Secondary Vendor Part #]) = 0 then null else replace([Secondary Vendor Part #], '''', '') end as secondaryVendorPartNumber,
  110. [PPAP] as ppap,
  111. case when len([File]) = 0 then null else REPLACE([File], '''', '') end as [file],
  112. case when len(Cost) = 0 then null else replace(Cost, '''', '') end as stdCost,
  113. case when len(List) = 0 then null else replace(List, '''', '') end as listPrice,
  114. createDate as createDate,
  115. -1 as createUserId,
  116. createDate as updateDate,
  117. -1 as updateUserId,
  118. partCodeId as partCodeId,
  119. statusId as statusId,
  120. primaryCustomerId as primaryCustomerId,
  121. primaryVendorId as primaryVendorId,
  122. secondaryVendorId as secondaryVendorId,
  123. pickingLocationId as pickingLocationId,
  124. packingLocationId as packingLocationId,
  125. null as replacedById,
  126. null as replacesId,
  127. replace(Weight, '''', '') as weight
  128. from z_parts
  129. ) a
  130. --select Date, Signed from z_parts where createDate is null
  131. --update z_parts set createDate = CAST([Date] as datetime) where myid = 10061
  132. --declare @int int
  133. --set @int = 1
  134. --while @int < 21668
  135. --begin
  136. --select CAST(Date as datetime), @int from z_parts where myid = @int
  137. --select @int = @int + 1
  138. --end