Wednesday, May 9, 2012

Save SQL Server Management Studio Output in a Pipe-Delimited File

In the event that you would like to obtain a pipe-delimited (i.e. '|') output file of data obtained from a query executed in SQL Server Management Studio, here is a quick procedure for making that happen:

If you're using Windows Server 2008 R2:

  1. Click Start -> Control Panel
  2. Click Clock, Language, and Region
  3. Click Change the date, time, or number format
  4. Click the Additional settings... button
  5. In the List separator field, replace ',' with '|'
  6. Click Apply
  7. Click OK
  8. Click OK
  9. Open SQL Management Studio and execute your query
  10. Write click in the Results window and select Save Results As...
  11. Select the appropriate directory path
  12. For File name:, enter an appropriate filename
  13. For Save as type:, select CSV (Comma delimited)
  14. Click Save
  15. You may now open the file in Notepad and confirm that the output is indeed pipe-delimited as opposed to comma-delimited
Once you have the pipe-delimited output you desire, the procedure to reset back to comma delimited is as follows:

  1. Click Start -> Control Panel
  2. Click Clock, Language, and Region
  3. Click Change the date, time, or number format
  4. Click the Additional settings... button
  5. In the List separator field, replace '|' with ','
  6. Click Apply
  7. Click OK
  8. Click OK
The procedures will be slightly different for other MS operating systems, but the concept will be the same.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.