Monday, February 20, 2012

Record set to text with separator

Hi all!
I have a bunch of stored procedures that all return record sets. Now I want
the results of these record sets to a file, with a special character to
separate the columns. How can I accomplish that?
Example:
Col1 Col2
-- --
Hi all
Be nice
...should become...
1#Hi#all
2#Be#nice
- Kristoffer -
The easiest way is to run them in Query Analyzer. Go to
Tools/Options/Results and pick Results to File and Custom Delimiter. Then
execute your proc.
Jeff Duncan
MCDBA, MCSE+I
"Kristoffer Persson" <hidden> wrote in message
news:OefzTQqMEHA.2532@.TK2MSFTNGP10.phx.gbl...
> Hi all!
> I have a bunch of stored procedures that all return record sets. Now I
want
> the results of these record sets to a file, with a special character to
> separate the columns. How can I accomplish that?
> Example:
> Col1 Col2
> -- --
> Hi all
> Be nice
> ...should become...
> 1#Hi#all
> 2#Be#nice
> - Kristoffer -
>
>
|||"Jeff Duncan" <jduncan@.gtefcu.org> wrote in message
news:uRjuJUqMEHA.3292@.TK2MSFTNGP11.phx.gbl...
> The easiest way is to run them in Query Analyzer. Go to
> Tools/Options/Results and pick Results to File and Custom Delimiter. Then
> execute your proc.
Yes, I am doing that for testing. Now I want to automate it.
Does anyone know of a good way?
- Kristoffer -
|||You can also do all of the above mentioned by doing a simple export data
using the DTS Wizard. You can select your source to be your DB and the
Destination to be a text file. Use a SQL query at the source and just have
it execute your stored proc. you can set your custom delimiters you need
for the output file. You can save that as a DTS package and rerun it any
time.
OR
you could create another proc that just selects the # in between and use BCP
to pump out the data to text
http://msdn.microsoft.com/library/de...p_bcp_61et.asp
Jeff Duncan
MCDBA, MCSE+I
"Kristoffer Persson" <hidden> wrote in message
news:OVQ4%23hqMEHA.268@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> "Jeff Duncan" <jduncan@.gtefcu.org> wrote in message
> news:uRjuJUqMEHA.3292@.TK2MSFTNGP11.phx.gbl...
Then
> Yes, I am doing that for testing. Now I want to automate it.
> Does anyone know of a good way?
> - Kristoffer -
>
|||I was thinking BCP would work, but it seems very complicated to use.
The DTS approach seems even better, if it works with MSDE. Does it?
That leaves only one question on the topic: How do I remove the empty rows
that appear between the returned recordsets?
Thank you!
- Kristoffer -
"Jeff Duncan" <jduncan@.gtefcu.org> wrote in message
news:eoPs4tqMEHA.4036@.TK2MSFTNGP12.phx.gbl...
> You can also do all of the above mentioned by doing a simple export data
> using the DTS Wizard.
> OR
> you could create another proc that just selects the # in between and use
BCP
> to pump out the data to text
>
http://msdn.microsoft.com/library/de...p_bcp_61et.asp
|||DTS Comes with SQL Server and not MSDE. However if you have a SQL Server
you can create a DTS package there and easily have your source be the MSDE
DB on the other box.
Jeff Duncan
MCDBA, MCSE+I
"Kristoffer Persson" <hidden> wrote in message
news:uxwoXzqMEHA.740@.TK2MSFTNGP12.phx.gbl...
> I was thinking BCP would work, but it seems very complicated to use.
> The DTS approach seems even better, if it works with MSDE. Does it?
> That leaves only one question on the topic: How do I remove the empty rows
> that appear between the returned recordsets?
> Thank you!
> - Kristoffer -
> "Jeff Duncan" <jduncan@.gtefcu.org> wrote in message
> news:eoPs4tqMEHA.4036@.TK2MSFTNGP12.phx.gbl...
> BCP
>
http://msdn.microsoft.com/library/de...p_bcp_61et.asp
>

No comments:

Post a Comment