I'm making some test variable and I insert a new line character into it. When I print it everything is ok, 1 word is below the second one. But when I write the value of this variable into *.txt file the new line character doesn't work. Here is my example:
DECLARE @cmd varchar(200), @var varchar(200)
SET @var = 'Hello' + CHAR(13) + 'world'
SET @cmd = 'echo ' + @var + ' > E:\s.txt'
print @cmd
EXEC master..xp_cmdshell @cmd
I was trying with DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
or \r\n
instead of this CHAR(13)
but no effect :/ Could someone give me small hint about this problem?
I'm using Microsoft SQL Server 2008 R2