title: Add custom text + variable to a varchar in sql
body: <p>i'm trying to make a txt file with a single command line output in it.
  However for some reason it doesn't want to add the text and the test name into it..
  Here's my code:</p>
  
  <pre><code>    declare @command AS varchar(200)
  declare @cmd AS varchar(200)
  declare @input AS varchar(200)
  declare @timeinput AS varchar(200)
  declare @test AS varchar(1000)
  declare @failureid as int
  
  select @timeinput = (select time from inserted)
  select @input = (select action from inserted)
  select @failureid = (select failureId from inserted)
  
  select @test = (select name from dbo.Alert where FailureId = @failureid)
  
  
  if (@input = 'start')
  BEGIN
  set @command = ('EnableTest' + @test)
  END
  
  if (@input = 'stop')
  BEGIN
  set @command = ('DisableTest' + @test)
  END
  
  if (@input = 'pauze')
  set @command = ('PauseTest' + @test + @timeinput)
  END
  
  SET @cmd = 'echo ' + @command + ' &gt; F:\commandfolder\testing.HMS'
  EXECUTE Master.dbo.xp_CmdShell @cmd
  </code></pre>
  
  <p>and the output in the HMS file is: DisableTest (with the testname missing)
  The @test doesn't add into the file.</p>
  
  <p>The data in my tables is correct as far as I know
  Any ideas?</p>
  
  <p>Thanks in advance &amp; kind regards,</p>
  
  <p>Dave</p>