I am using BCP to export a SQL view to a text file. It works fine except the file has a static name. I am trying to get a dynamic file name.
I have a field in my view (vwWorkOrderAdjust) named wo_id
Instead of exporting the file named forMas90.txt I am trying to name the file with the wo_id and Hour_Minute_Second So if it is 5:30:33 PM and I am exporting work order 18898 I want the file to be saved as 18898_17_30_33.txt.
Is this possible?
ALTER PROCEDURE [dbo].[spPostUpload] AS
DECLARE @sql varchar(8000)
SELECT @sql= 'bcp iris..vwWorkOrderAdjust out C:\Inetpub\wwwroot\Iris\htdocs\textfiles\forMas90.txt -c -t, -T -S'
EXEC master..xp_cmdshell @sql