I have a little issue about logging files. I want to export this string called test, but i dont know why i cant do that.
I know that command_string should not have more than 8000 characters. I don't understand why this doesn't work. Can anyone help me with that?
DECLARE @LogFilePath varchar(max)
DECLARE @teste varchar(max) = 'columnsToSelect = [street],[locality],[postalCode1],[postalCode2],[isMainAddress]'
SET @LogFilePath = 'C:\Users\epascoal\Documents\Logs\Log_ImportToSQ.txt'
SET @cmd ='echo '+ @teste +' >>'+@LogFilePath
exec master..xp_cmdshell @cmd
This works with smaller strings.
Question:How can i write large strings into a logfile?
Thanks in advance.
echo
on command line has no 'out' parameter, and it wouldn't recognize it anyway without the parameters being properly escaped.You can try actually redirecting it:
Redirecting like this is supposed to work.