Home All Groups Group Topic Archive Search About

select results into file



Author
18 May 2005 12:35 AM
maxzsim
Hi,

i believe the results from a select query can be output into a file but i
do not want to use the Query Analyzer's -->Query-->Results to file , so how
can i specify the file name directly from the SELECT statement ?

e.g SELECT * from a and out into a file

appreciate any advice

tks & rdgs

Author
18 May 2005 1:41 AM
Armando Prato
Try using isql via the query analyzer as a quick and dirty method

replace <user>, <password>, <server>, <database>, & <query>

it produces a file in your c: root drive called fileout.txt

use master
go
xp_cmdshell
'isql -U<user> -P<password> -S<server> -d<database> -w8000 -q"<query>" -oc:\
fileout.txt'



Show quoteHide quote
"maxzsim" <maxz***@discussions.microsoft.com> wrote in message
news:DFA8AE30-0AEF-43CB-94DD-C94644B09BE2@microsoft.com...
> Hi,
>
>  i believe the results from a select query can be output into a file but i
> do not want to use the Query Analyzer's -->Query-->Results to file , so
how
> can i specify the file name directly from the SELECT statement ?
>
> e.g SELECT * from a and out into a file
>
> appreciate any advice
>
> tks & rdgs
Are all your drivers up to date? click for free checkup

Author
18 May 2005 3:13 AM
maxzsim
Hi,

  Actually i need to schedule the task so i was thinking if i could directly
specify from the selct statement then i need not keep track of too much things

anyway , i have created a DTSjob to do the export into a text file

tks & rdgs

Show quoteHide quote
"Armando Prato" wrote:

>
> Try using isql via the query analyzer as a quick and dirty method
>
> replace <user>, <password>, <server>, <database>, & <query>
>
> it produces a file in your c: root drive called fileout.txt
>
> use master
> go
> xp_cmdshell
> 'isql -U<user> -P<password> -S<server> -d<database> -w8000 -q"<query>" -oc:\
> fileout.txt'
>
>
>
> "maxzsim" <maxz***@discussions.microsoft.com> wrote in message
> news:DFA8AE30-0AEF-43CB-94DD-C94644B09BE2@microsoft.com...
> > Hi,
> >
> >  i believe the results from a select query can be output into a file but i
> > do not want to use the Query Analyzer's -->Query-->Results to file , so
> how
> > can i specify the file name directly from the SELECT statement ?
> >
> > e.g SELECT * from a and out into a file
> >
> > appreciate any advice
> >
> > tks & rdgs
>
>
>

Bookmark and Share