|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL Script to output to text file
I have a sql statement that is selecting the data that I need to use in a flat-file application. I need an hourly job to run that statement and put it's contents into a text file.
After that, I will ftp into the system to retrieve that txt file and process it on the remote system. What I need help with is scheduling that job to run and putting the resultset into a text file. I haven't seen to much help on outputting to txt files. The only thing I have seen duscussed is bcp, but that seems more like a utility to dump all the data (or some columns). I need to select based on certain criteria so that's why I have the SQL statement. Thanks! |
|
#2
|
|||
|
|||
|
try osql
Take a look in SQL Books Online, under the topic osql, or open a command window on a workstation that has SQL Server client tools, and type osql /??.
It's a command-line utility that lets you run almost any query or procedure and store the output in a text file. You can set it up within a DOS command file, spawn to it from other code, or run it interactively. A simple example is...note that the parameters are case-sensitive. osql -Sservername -dDatabaseName -UUsername -Ppassword -o"c:\junk.txt" -Q"select * from stations" Error messages or results will end up in "c:\junk.txt" |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > SQL Script to output to text file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|