April 7, 2016 at 4:24 am
I have an SQL Job set up to send a file to a folder. I need to add getdate() in the format, yyyymmdd, to the end of the filename but, I can't seem to get the correct syntax. Any thoughts?
DECLARE @cmd VARCHAR(2048)
SET @cmd = 'bcp "EXEC SigHealth..spAPSDownload_Lab" queryout'
+' "\\sh-sftp\data$\aps_billing\APS_Lab.txt" -c -T -t^|'
+' -SLOCALHOST" '
print @cmd
EXEC master..xp_cmdshell @cmd, NO_OUTPUT
April 7, 2016 at 4:30 am
DECLARE @DateStr VARCHAR(12);
SET @DateStr = REPLACE(CONVERT(VARCHAR(12), GETDATE(),102),'.','');
DECLARE @cmd VARCHAR(2048)
SET @cmd = 'bcp "EXEC SigHealth..spAPSDownload_Lab" queryout'
+' "\\sh-sftp\data$\aps_billing\APS_Lab_'+@DateStr+'.TXT" -c -T -t^|'
+' -SLOCALHOST" '
print @cmd
April 7, 2016 at 5:10 am
Perfect.
Thanx.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply