all groups > sql server programming > november 2004 >
You're in the

sql server programming

group:

output to text file


output to text file Sri
11/3/2004 10:18:02 PM
sql server programming:
How do you save the output of a query/stored procedure to a text file?
Re: output to text file Sri
11/3/2004 10:39:01 PM
I am sorry, from query analyser or using stored procedure

[quoted text, click to view]
Re: output to text file Sri
11/4/2004 12:20:02 AM
Hi Uri,
Thanks for your solution. But when I execute the statement in query analyser,
I am getting the following error.

Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '"' '.

Please help me.

[quoted text, click to view]
Re: output to text file David Gugick
11/4/2004 1:31:28 AM
[quoted text, click to view]

From Query Analyzer? From somewhere else? What are you using?

--
David Gugick
Imceda Software
www.imceda.com
Re: output to text file Uri Dimant
11/4/2004 8:34:44 AM
Sri
EXEC master..xp_execresultset N'SELECT
''EXEC master..xp_cmdshell ''''BCP "SELECT * FROM Northwind..Orders "
queryout "C:\Temp\1.csv" -w -t"|" -T -S"''+@@servername+''"'''' ''
',N'Northwind'




[quoted text, click to view]

Re: output to text file Uri Dimant
11/4/2004 10:25:11 AM
Hi
Strange, on my workstation it works fine
create table ww
(
col1 int,
col2 varchar(50),
col3 varchar (50)
)

insert into ww values (47,'ReadyShip','(503)888-999')
insert into ww values (48,'MyShipper','(503)1212-454')
insert into ww values (49,'ReadyShip','(45)888-999')
insert into ww values (50,'MyShipper','(545)1212-454')

---Prompt command
bcp northwind.dbo.ww out d:\test1.txt -c -t, -SSERVER -Usa -P.....

exec master..xp_cmdshell 'BCP northwind..ww out
d:\test1.txt -c -C850 -Sserver -Usa -P....'





[quoted text, click to view]

Re: output to text file avnrao
11/4/2004 12:04:11 PM
hey Sri,

check your previous post Text File. the links are already provided to write
to a text file.
if that doesnt serve your purpose, tell us what your requirement exactly
is...
do you want to write the output of the query to text file in SQL or in any
other language?

Av.
http://avdotnet.rediffblogs.com
http://www28.brinkster.com/avdotnet

[quoted text, click to view]

Re: output to text file Roji. P. Thomas
11/4/2004 12:12:07 PM
From Query Analyser.

Query --> Results to File
--
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com


[quoted text, click to view]

AddThis Social Bookmark Button