Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Output results to text file Expand / Collapse
Author
Message
Posted Thursday, February 21, 2008 7:41 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 12:28 PM
Points: 3,467, Visits: 1,828
And that typically you find the easy method after spending hours and hours on the harder methods.

Kenneth


Kenneth Fisher
I strive to live in a world where a chicken can cross the road without being questioned about its motives.
--------------------------------------------------------------------------------
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Link to my Blog Post --> www.SQLStudies.com
Post #458547
Posted Thursday, February 5, 2009 6:40 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, August 4, 2014 10:13 AM
Points: 53, Visits: 231
Try this to write output to text files
:P
Set ANSI_Nulls on
set QUOTED_IDENTIFIER ON

Declare @cmd varchar(1000)
Declare @WorkfileName varchar(128)
Declare @WorkDir varchar(100)

Select @WorkfileName = 'test1.txt'
Select @WorkDir = '\\Phivmfile001\ds\Production\Input\Tests\'

Select @cmd = 'echo ' + 'Print "Hello" ' + ' > ' + @WorkDir + @WorkfileName
exec master..xp_cmdshell @cmd, no_output

Select @cmd = 'echo ' + 'Print "Hello" ' + ' >> ' + @WorkDir + @WorkfileName
exec master..xp_cmdshell @cmd, no_output
Post #650784
Posted Thursday, February 5, 2009 6:49 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, March 27, 2014 11:17 PM
Points: 309, Visits: 814
you can download trial version of third party tools which will export SQL result set to Excel, CSV, PDF etc and give a try nisha

Regards,
Sakthi
My Blog -> http://www.sqlserverdba.co.cc
Post #650795
Posted Monday, July 8, 2013 2:33 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 23, 2014 5:16 AM
Points: 1, Visits: 85
dfgfdgh
Post #1471087
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse