Friday, February 3, 2017
SQL output to text file
--Export to File
DECLARE @command VARCHAR(1000)
SET @command = 'BCP "SELECT * from ESL.dbo.BIT_MAGNAFile" queryout "C:\Temp\myfile_'
+ CONVERT(VARCHAR, YEAR(GETDATE())) + RIGHT('00'
+ CONVERT(VARCHAR, MONTH(GETDATE())),
2) + RIGHT('00'
+ CONVERT(VARCHAR, DAY(GETDATE())),
2)
+ '.txt" -c -T -t "|" -S "ESHODB01\ESLNAV"'
EXEC xp_cmdshell @command
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment