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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 create file

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-31 : 08:18:31
irina writes "hi!

i would like to write the contents of a variable to a text file. I would like to know if there are some function that would help me writiing on a new line in a text file, or add text to the file? thanks"

X002548
Not Just a Number

15586 Posts

Posted - 2003-12-31 : 10:42:48
How about something like


SET @var = RTrim(Convert(Char(20),@Log_Id)) + '|U|'+RTrim(Convert(char(50),GetDate(),109))+'|Starting ETRS Load Process'
SET @cmd = 'echo ' + '"|' + @var + '|"' + ' > d:\data\Tax\ASI_log_out.txt'
SET @Command_string = 'EXEC master..xp_cmdshell ''' + @cmd + ''', NO_OUTPUT'

Exec(@Command_String)


That creates/over-write a file...to append use >>



Brett

8-)
Go to Top of Page
   

- Advertisement -