Files
GateDge2023_ljy/05.长园/CYG/20241114_应收发票更新.sql
PastSaid 9725ab5376 a
2024-12-05 15:39:19 +08:00

51 lines
1.7 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--1.开启Ad Hoc Distributed Queries组件在sql查询编辑器中执行如下语句
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
----2.关闭Ad Hoc Distributed Queries组件在sql查询编辑器中执行如下语句
--exec sp_configure 'Ad Hoc Distributed Queries',0
--reconfigure
--exec sp_configure 'show advanced options',0
--reconfigure
--DROP TABLE 应收单临时数据_20241114
--SELECT * FROM 税收分类编码导入EXCEL
--把excel数据导入数据库
--DROP TABLE 销售订单_2024052116060442_100015
;WITH #table1 AS (
SELECT *
--INTO 销售订单_2024052116060442_100015
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0'
,'Excel 12.0;HDR=Yes;IMEX=2;DATABASE=C:\Users\Fareoh\Downloads\工作簿1.xlsx'
,'SELECT * FROM [Sheet1$]')
--WHERE 订单日期 != '合计'
)
SELECT ,,,
INTO _20241114
FROM #table1
GROUP BY ,,,
SELECT A.F_number,B.F_number,
A.FMailingCompany,B.FMailingCompany,A.FDeliveryCompany,B.FDeliveryCompany,A.Fslipnumber,B.Fslipnumber
,A.F_CYG_TEXT3 , B.F_CYG_TEXT3,A.FBILLNUM , B.FBILLNUM,A.FBILLTIME ,B.FBILLTIME,B.FDocumentStatus
,t2.*
FROM t_AR_receivable A
INNER JOIN t_AR_receivableInvoice B ON B.FNUMBER=A.FBILLNO
INNER JOIN _20241114 t2 on t2. = A.FBILLNO
WHERE B.FDocumentStatus = 'C'
AND A.F_CYG_TEXT3 = ''
--定时任务 最终sql
UPDATE A SET A.F_number=B.F_number,
A.FMailingCompany=B.FMailingCompany,A.FDeliveryCompany=B.FDeliveryCompany,A.Fslipnumber=B.Fslipnumber
,A.F_CYG_TEXT3 = B.F_CYG_TEXT3,A.FBILLNUM = B.FBILLNUM,A.FBILLTIME = B.FBILLTIME
FROM t_AR_receivable A
INNER JOIN t_AR_receivableInvoice B ON B.FNUMBER=A.FBILLNO
WHERE B.FDocumentStatus = 'C'
AND B.F_CYG_TEXT3 != ''
AND B.FBILLNUM != ''
AND B.FBILLTIME != ''