title: Declare string in quote in SQL Server
body: <p>I am trying to run a SQL command but I am getting error message of <strong>Not a Valid Identifier</strong>.</p>
  
  <p>If I am using this command,</p>
  
  <pre><code>EXEC xp_cmdshell N'mkdir C:\Users\PC\Desktop\Backup\1042012'
  GO
  </code></pre>
  
  <p>then this command works properly</p>
  
  <p>But, if I am using this command</p>
  
  <pre><code>DECLARE @CurrentDate varchar(50)
  DECLARE @Path varchar(200)
  DECLARE @Command varchar(200)
  
  SET @CurrentDate = GETDATE()
  SET @Path = N'C:\Users\PC\Desktop\Backup'
  SET @Command = N'xp_cmdshell " ' + 'MKDIR' + ' '+ @Path + '\' +  @CurrentDate + '" '
  
  EXEC @Command
  GO
  </code></pre>
  
  <p>I am getting that error message. Is something to do with declaring a string properly or not.</p>