上代码
EXEC master..xp_cmdshell 'del D:\PPReport\To_KEAS_GDC_ASN\"dzw report.xlsx"' --复制文件 EXEC master..xp_cmdshell 'COPY D:\PPReport\To_KEAS_GDC_ASN\report_Empty.xlsx D:\PPReport\To_KEAS_GDC_ASN\report_Empty2.xlsx' --这里建议分开,不然容易在没有report_Empty2.xlsx的时候调用进行 --存储过程代码优先自检报错,建议分开限制性前面的后判断文件存在再进行操作 INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=D:\PPReport\To_KEAS_GDC_ASN\report_Empty2.xlsx', 'select ControlNo,FaultyPN,ShippedPN,PPID,Returnto,TPRShippedDate,[RTV Order Number] FROM [sheet1$]') SELECT s.ControlNo,s.ShippedPN,s.ShippedPN,s.PPID,s.Returnto,s.TPRShippedDate,a.[RTV Number] FROM dbo.s(NOLOCK) s INNER JOIN dbo.A(NOLOCK) a ON s.ControlNo = a.ControlNo --reName exec master..xp_cmdshell 'ren D:\PPReport\To_KEAS_GDC_ASN\report_Empty2.xlsx "dzw report.xlsx"'
标签:Execl,xlsx,SqlServer,KEAS,report,GDC,PPReport,将表,ASN From: https://www.cnblogs.com/dzw159/p/16787877.html