title: Problem with BCP writing to .txt file from SQL
body: <p>Im using Sql2008 trying to run this BCP command but it never creates the file.</p>
  
  <pre><code>-- Export query
    DECLARE @qry2 VARCHAR(1000)
    SET @qry2 = 'SELECT * FROM @SkippedProductsTable'
  
    -- Folder we will be putting the file in         
    DECLARE @incomingfolder VARCHAR(1000)
    SET @incomingfolder = 'c:\Logs'
  
    DECLARE @bcpCommand VARCHAR(2000)
    SET @bcpCommand = 'bcp "'+@qry2+'" queryout "'+@incomingfolder+'\SkippedProducts-'+CAST(@StoreMatchCode AS VARCHAR)+'-'+'.txt" -c -T'
  
    PRINT @bcpCommand
    EXEC MASTER..xp_cmdshell @bcpCommand, no_output
  </code></pre>
  
  <p>The created command looks like:</p>
  
  <pre><code>bcp "SELECT * FROM @SkippedProductsTable" queryout "c:\Logs\SkippedProducts-1330-.txt" -c -T
  </code></pre>
  
  <p>Can anyone suggest what could be going wrong? I've never used BCP before and not really sure where to start looking.</p>
  
  <p>As a start I know that the folder deffinately exists at that location</p>