August 21, 2001 at 2:11 am
Hello,
I am trying to write the output of a stored procedure to a txt file. I am unable to find any technical matter on the same.
can anyone help me in this regard.
I want to call that output txt file from a ASP page later.
Thanks
August 21, 2001 at 4:44 am
One kinda cool way to do is by using the web export wizard.
Andy
August 21, 2001 at 6:20 am
Thers one article from Brian Knight, that explain how to do that using Query Analyzer.
http://www.sqlservercentral.com/columnists/bknight/tippipequery.asp.
WolfJr.
August 21, 2001 at 10:25 pm
You may want to play with calling the sp using isql or osql (see bellow pulled from T-SQL help file):
Using the osql Utility (isql could be used too)
The osql utility is a Microsoft® Win32® command prompt utility for ad hoc, interactive execution of Transact-SQL statements and scripts. To use osql, users must understand Transact-SQL.
The osql utility is typically used in these ways:
Users interactively enter Transact-SQL statements in a manner similar to working on the command prompt. The results are displayed in the command prompt window.
Users submit an osql job either specifying a single Transact-SQL statement to execute or pointing the utility to a text file that contains Transact-SQL statements to execute. The output is usually directed to a text file, but it also can be displayed in the command prompt window.
Other options are that you could build an Active X control that you could instantiate in the sp and feed it the output parameters having the Active X control assemble the resulting text file and output it using the file system object.
February 18, 2002 at 2:40 pm
To output the results of a script.
osql -E -d%database% -Q"exec sp_..." -n -ooutput.txt
You can use the -i flag to execute a script
and -o or the >
>> appends the output to the file.
March 20, 2002 at 1:22 pm
Can't you try using xp_cmdshell?
Give me a fish, you feed me for a day! Teach me to fish, you feed me for a life time.
January 31, 2019 at 5:28 pm
wolfjr - Tuesday, August 21, 2001 6:20 AMThers one article from Brian Knight, that explain how to do that using Query Analyzer. http://www.sqlservercentral.com/columnists/bknight/tippipequery.asp. WolfJr.
sorry - we were looking from Stored procedure - not from direct select command.
January 31, 2019 at 6:12 pm
Umm... that post you're adding to is SEVENTEEN YEARS old.
How about...
https://sqlwithmanoj.com/tag/bcp-queryout/
February 7, 2019 at 8:05 am
pietlinden - Thursday, January 31, 2019 6:12 PMUmm... that post you're adding to is SEVENTEEN YEARS old.
How about...
https://sqlwithmanoj.com/tag/bcp-queryout/
Heh... ya gotta admit, though... it's still a frequent question. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply