我有下面的代碼,但現在需要對銷售數據文件的唯一文件名(日期末)唯一的輸出文件名
USE [KevinMayhewLive]
GO
/****** Object: StoredProcedure [dbo].[toFileSalesData] Script Date: 06/19/2017 13:36:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[toFileSalesData]
as
--xp_cmdshell will shell out to the command line to run bcp
--the user account that runs this procedure should have file access to create and write files
--bcp does not append to files, all data will be overwritten each time this procedure runs
EXEC KevinMayhewLive..xp_cmdshell 'bcp "SELECT * FROM KevinMayhewLive.dbo.KM_CUSTOMER_DATA" queryout \\SERVER3\Docs\Emarsys_Sync\Customer_data\CUSTOMER_DATA.csv -c -t, -T -S'
EXEC KevinMayhewLive..xp_cmdshell 'bcp "SELECT * FROM KevinMayhewLive.dbo.KM_SALES_DATA" queryout \\SERVER3\Docs\Emarsys_Sync\Sales_Data\sales_items.csv -c -t, -T -S'
你的意思是唯一的文件名?你的查詢有兩個不同的文件名輸出 –
嗨,歡迎來到SO。目前還不清楚你想從這個問題中得到什麼。看來你想每次執行這個SalesData文件都有一個唯一的名字?對這個名字的結構有什麼想法?那個選擇語句剛好在ALTER之前有什麼意義? –
啊忘了刪除(以前的一些不好的建議) –