SET @variable = 1 exec master..xp_cmdshell '@echo test message no. @variable' >> d:\output.txt'
declare @variable int SET @variable = 1 exec ('exec master..xp_cmdshell ''@echo test message no.' +@variable+ '>> d:\output.txt''')