December 17, 2008 at 12:17 pm
I want to save query result in pipe delimited form. I am wondering how to do it?
By default, results to grid can be saved in csv format.
I couldn't find a way to get result set in either pipe delimited form.
Thanks,
December 17, 2008 at 12:35 pm
The best way I can think of is to use the sqlcmd.exe. That allows you to format the output pretty much any way you want.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 17, 2008 at 2:16 pm
If your using Microsoft Sql Server management studio this is Configurable.
(actually almost the exact same in query analyzer)
Tool--> Options -->Query Results --> Sql Server --> Results to Text.
Change output format from Tab Delimited to Custom Delimited.
Put a Pipe in the Custom Delimiter Box.
Go back to your query select Query --> Results to File. Execute file, Give it a Disk path and a name.
The file will be your name with a .rpt Extension, you can rename it to have a .txt extension.
You obviously have to set the results to text value back to your previous setting if you don't want this permanently.
Works good for a one time once in a while thing. but if you must generate this file frequently I would look at creating a SSIS Package. or as suggested above.
December 17, 2008 at 7:58 pm
Thanks to both of you. Through your responses, i was able to do it. 🙂
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply