Is it possible to send the output of a query to a text file in a stored procedure When I run stored procedure in Query Analyzer I am able to do that and I am wondering if this is possible in a automated way
Is it possible to send the output of a query to a text file in a stored procedure When I run stored procedure in Query Analyzer I am able to do that and I am wondering if this is possible in a automated way
output to a text file
Alexey Vishnyakov
HTH, Jens SUessmeyer.
---
http://www.sqlserver2005.de
---
Zooz
Hi,
you can call the bcp utility from stored procedure..
create procedure copytoTextFile as
exec master..xp_cmdshell 'bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname" queryout c:\Authors.txt -c -S -Usa -Ptest'
Jehan Badshah
Tryin2Bgood
This will work if xp_cmdshell is enabled
DECLARE
@isqlString varchar(255) SELECT @isqlString = 'isql -Q "SELECT top 10 FROM TABLE" -E -o C:\Results.txt' EXEC master..xp_cmdshell @isqlString