SQL Server - Output to CSV

advertisement
Output SQL Server Queries in a CSV Format
The following was performed using SQL Server Express 2005. The steps may differ
slightly on 2005, 2008, 2012 etc.
Start and login to the SQL Server Management Studio
Ian Cooke
1 of 5
Output SQL Server Queries in a CSV Format
Click new query
Ian Cooke
2 of 5
Output SQL Server Queries in a CSV Format
Click query, query options, text. Set the output format to Comma delimited.
Ian Cooke
3 of 5
Output SQL Server Queries in a CSV Format
Click query, result to. Set “Result to File”
Ian Cooke
4 of 5
Output SQL Server Queries in a CSV Format
For EACH table to be queried –
“SET NOCOUNT ON” – prevents the number of records from being returned
SELECT * FROM the table required.
When the query runs set the save in a file the same as “table name”
Ian Cooke
5 of 5
Download