Wednesday, March 7, 2012

q; output to a text file

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 tha
t
and I am wondering if this is possible in a automated way?Not directly. But indirectly, you can use xp_cmdshell and BCP or OSQL. Note
that the file is created
by the database server. If you are on 2005, you can also call an Assembly, i
f that suits you better.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:33A04A73-5811-4479-A181-67A3F999C770@.microsoft.com...
> 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 t
hat
> and I am wondering if this is possible in a automated way?|||In order to output to a file, you would have to use ( xp_cmdshell and OSQL )
OR bcp.
Check [ BCP Utility ] or [OSQL ] in Book Online
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:33A04A73-5811-4479-A181-67A3F999C770@.microsoft.com...
> 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?

No comments:

Post a Comment