Exporting data out of SQL is an easy task, but there’s always a few snags that’ll crop up here and there, like always.
This is just a quick note on the default export file options when using SQL Server Management Studio.
To export a query the simplest way, it would be for us to click Results to File as arrowed below.
When you run the query, it’ll prompt asking where and what to save the file as.
The default file type is as shown above, a .rpt file. If we open that in NotePad++, it’s looking like this;
We’ll save it as CSV this time.
You’ll probably want to change the delimiter after looking at the file.
We’ll have to go into the options of SSMS as shown below.
Into Results to Text, we can see the output format is set to Column aligned.
We’ll change that default value to Comma delimited.
You’ll need to disconnect your current session within the Object Explorer and connect back to the SQL Server.
Now, if we run that query and check the output file;
Looking better now!