Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
razeena
Yak Posting Veteran
54 Posts |
Posted - 2011-10-19 : 08:08:35
|
Hi, I have a sp which saves the necessary informationregarding the status of action(whether success or failure, rows affected etc) to a log tablesay(StatusLog)After this, I was sending a database mailwith information taken from the log table via sp_send_dbmail. Now I would like towrite the status information to a 'txt' file instead of sending via mail.How can I write to a text file from a stored procedure in ms sql server 2005? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
razeena
Yak Posting Veteran
54 Posts |
Posted - 2011-10-20 : 07:49:58
|
Thanks.I tried something like below.DECLARE @cmd varchar(256), @var varchar(50)SET @var = 'Hello world!' +CHAR(13)+CHAR(10)+ 'This is second line'print @varSET @cmd = 'echo>d:\myfile.txt ' + @var EXEC master..xp_cmdshell @cmd, no_outputBut it is not saving the second line in the file.How can I manage the line breaks/new lines?quote: Originally posted by visakh16 have a look at bcphttp://www.sqlteam.com/article/exporting-data-programatically-with-bcp-and-xp_cmdshell------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
|
|
jassi.singh
Posting Yak Master
122 Posts |
|
lock
Starting Member
1 Post |
Posted - 2015-02-14 : 05:32:10
|
??????? 19???? ????http://goo.gl/x2TTfF??????? 19???? ??? ??????? 19????, ??????? 19????, ??????? 19???? ???, ??????? 19???? ??, ??????? 19???? ??, fc2 ??????? 19???? |
|
|
pradeepbliss
Starting Member
28 Posts |
Posted - 2015-02-17 : 07:31:48
|
quote: Originally posted by lock ??????? 19???? ????http://goo.gl/x2TTfF??????? 19???? ??? ??????? 19????, ??????? 19????, ??????? 19???? ???, ??????? 19???? ??, ??????? 19???? ??, fc2 ??????? 19????
Plz behave like professional...Admin plz block this type of forum members... |
|
|
pradeepbliss
Starting Member
28 Posts |
Posted - 2015-02-17 : 08:45:10
|
DECLARE @cmd varchar(256), @var varchar(50),@var1 varchar(50)SET @var = 'Hello world!' set @var1 = 'This is second line'SET @cmd = '(echo '+@var+' && echo '+@var1+') >d:\SprintTask.txt'EXEC master..xp_cmdshell @cmd, no_outputquote: Originally posted by razeena Hi, I have a sp which saves the necessary informationregarding the status of action(whether success or failure, rows affected etc) to a log tablesay(StatusLog)After this, I was sending a database mailwith information taken from the log table via sp_send_dbmail. Now I would like towrite the status information to a 'txt' file instead of sending via mail.How can I write to a text file from a stored procedure in ms sql server 2005?
|
|
|
|
|
|
|
|