In one line, but without deleting ads. EXEC and sp_executesql do not allow the use of function calls in a command or parameters. Therefore, you need to declare a string variable to insert CHAR (9) into the command:
exec('DECLARE @str varCHAR(200);
set @str = ''xp_cmdshell ''''echo '' + CHAR(9) + ''Some text>> C:\test.txt'''', NO_OUTPUT'';
EXEC(@str)');
valex source
share