export to text file + SQL
-
How to export query results into text file ?
-
How to export query results into text file ?
For That You Have To Activate Few Services In SQL Server :: Execute This Command Set; EXEC master.dbo.sp_configure 'show advanced options', 1 RECONFIGURE EXEC master.dbo.sp_configure 'xp_cmdshell', 1 RECONFIGURE Now To Get Output of any SQL query in a text file write this query: EXEC xp_cmdshell 'bcp "YOUR QUERY HERE" queryout "Location Of TextFile Here" -T -c -t,'
- Happy Coding - Vishal Vashishta
-
How to export query results into text file ?
-
Thanks For Reply . I have use this code :
EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE
EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGUREEXEC xp_cmdshell 'bcp "SELECT * FROM Silver.tblGroups" queryout "C:\bcptest2.txt" -T -S ALIJOONASUS\wintapsqlexpress -c -t,'
But i wanna to have
UTF-8
text file. and Secondly : How to haveColumns Name
also