Groups | Blog | Home
all groups > sql server programming > july 2004 >

sql server programming : Direct text file output from T-SQL


B. Chernick
7/29/2004 8:37:11 PM
Is it possible in T-SQL to directly send query results to a text file without the use of command line utilities and command shell procedure calls?

Steve Kass
7/30/2004 2:03:04 AM
There is a "Results to File..." option in Query Analyzer, but there is
no SQL statement to redirect output to a file, only the utilities Hari
mentioned..

Steve Kass
Drew University

[quoted text, click to view]
Hari Prasad
7/30/2004 9:43:50 AM
Hi,

Oracle uses spool commands. In SQL server you have to use one of the below:-

1. ISQL / OSQL
2. BCP OUT
3. DTS

Tahnks
Hari
MCDBA

[quoted text, click to view]
something like a 'SET OUTPUT <filename>' command with SELECT. I think he's
referring to a different db system. In any case I can't find anything like
it in SQL Server documentation.)

bojci
7/30/2004 9:46:04 AM
There is one more way as I wrote some days ago...

You can use Jet OLEDB driver with "sp_addlinkedserver" after this you can
use INSERT .. INTO statement to save queries into text files. See "OLE DB
Provider for Jet" in the BOL. ("Accessing and changing relational" data
section...)





[quoted text, click to view]
something like a 'SET OUTPUT <filename>' command with SELECT. I think he's
referring to a different db system. In any case I can't find anything like
it in SQL Server documentation.)

Steve Kass
7/31/2004 1:03:37 AM
Good tip! Here's an example:
http://groups.google.com/groups?q=sp_addlinkedserver+inconsequential

SK

[quoted text, click to view]
AddThis Social Bookmark Button