SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Output results to text file


Output results to text file

Author
Message
Kenneth Fisher
Kenneth Fisher
SSCertifiable
SSCertifiable (6.4K reputation)SSCertifiable (6.4K reputation)SSCertifiable (6.4K reputation)SSCertifiable (6.4K reputation)SSCertifiable (6.4K reputation)SSCertifiable (6.4K reputation)SSCertifiable (6.4K reputation)SSCertifiable (6.4K reputation)

Group: General Forum Members
Points: 6387 Visits: 2060
And that typically you find the easy method after spending hours and hours on the harder methods.

Kenneth

Kenneth FisherI 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
mfink
mfink
Old Hand
Old Hand (392 reputation)Old Hand (392 reputation)Old Hand (392 reputation)Old Hand (392 reputation)Old Hand (392 reputation)Old Hand (392 reputation)Old Hand (392 reputation)Old Hand (392 reputation)

Group: General Forum Members
Points: 392 Visits: 232
Try this to write output to text files
Tongue
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
Sakthivel Chidambaram
Sakthivel Chidambaram
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1403 Visits: 838
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
vikas.helpfriends
vikas.helpfriends
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 91
dfgfdgh
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search