I am exporting to a CSV using a job with xp_cmdshell. I need the filename to include a timestamp. The code I currently have is...
EXEC xp_cmdshell 'bcp "SELECT * FROM dbo.tablename" queryout "C:\filename-timestamp.csv" -T -c -t, '
As you can see, I need the 'timestamp' to be replaced with the actual timestamp, and for the format to be .csv, how can I achieve this?
