Home > Archive > MS SQL Server > May 2005 > select results into file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author select results into file
maxzsim

2005-05-17, 8:23 pm

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
Armando Prato

2005-05-17, 8:23 pm


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" <maxzsim@discussions.microsoft.com> wrote in message
news:DFA8AE30-0AEF-43CB-94DD- C94644B09BE2@microso
ft.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



maxzsim

2005-05-18, 3:23 am

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

"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" <maxzsim@discussions.microsoft.com> wrote in message
> news:DFA8AE30-0AEF-43CB-94DD- C94644B09BE2@microso
ft.com...
> how
>
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com