ZHJA_HJGL/DataBase/附件转换.sql

33 lines
1.6 KiB
Transact-SQL

--·¨ÂÉ·¨¹æ 96DE448F-0629-40BC-2222-3E79686D3343
SELECT AttachUrl,LawRegulationId FROM Common_LawRegulation
WHERE AttachUrl IS NOT NULL
--±ê×¼¹æ·¶ 46EE9F79-64CF-4BF4-2222-67E73B1ECB2F
SELECT AttachUrl,StandardId FROM Common_ConstructionStandardList
WHERE AttachUrl IS NOT NULL
INSERT INTO AttachFile (AttachFileId,ToKeyId,AttachSource,AttachUrl,MenuId)
SELECT A.StandardId
,A.StandardId
,'[ { "name": "'+(SUBSTRING(A.AttachUrl,CHARINDEX('~',A.AttachUrl)+1, (LEN(A.AttachUrl)- (charindex('.',reverse(A.AttachUrl))))))
+'", "type": "'+(right(A.AttachUrl,charindex('.',reverse(A.AttachUrl))-1))+'", "savedName": "'
+RIGHT(A.AttachUrl,charindex('\',reverse(A.AttachUrl))-1)+'", "size": 100, "id": "' +A.StandardId+'" }]'
,A.AttachUrl
,'46EE9F79-64CF-4BF4-2222-67E73B1ECB2F'
FROM Common_ConstructionStandardList AS A
WHERE A.AttachUrl IS NOT NULL AND charindex('.',reverse(A.AttachUrl)) > 0
AND A.StandardId NOT IN (SELECT ToKeyId FROM AttachFile)
GO
INSERT INTO AttachFile (AttachFileId,ToKeyId,AttachSource,AttachUrl,MenuId)
SELECT A.LawRegulationId
,A.LawRegulationId
,'[ { "name": "'+(SUBSTRING(A.AttachUrl,CHARINDEX('~',A.AttachUrl)+1, (LEN(A.AttachUrl)- (charindex('.',reverse(A.AttachUrl))))))
+'", "type": "'+(right(A.AttachUrl,charindex('.',reverse(A.AttachUrl))-1))+'", "savedName": "'
+RIGHT(A.AttachUrl,charindex('\',reverse(A.AttachUrl))-1)+'", "size": 100, "id": "' +A.LawRegulationId+'" }]'
,A.AttachUrl
,'96DE448F-0629-40BC-2222-3E79686D3343'
FROM Common_LawRegulation AS A
WHERE A.AttachUrl IS NOT NULL AND charindex('.',reverse(A.AttachUrl)) > 0
AND A.LawRegulationId NOT IN (SELECT ToKeyId FROM AttachFile)
GO