MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 15th, 2004, 02:52 PM
geoffm33 geoffm33 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Boston
Posts: 12 geoffm33 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 53 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old April 15th, 2004, 08:41 AM
tiny-r tiny-r is offline
SQL/VB Pgmr
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: NC
Posts: 3 tiny-r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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"

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > SQL Script to output to text file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway