title: sqlcmd error , Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'd '
body: <p>I trying to call a stored procedure:</p>
  
  <pre><code>sqlcmd -d jas_bis -Q "exec GenerateXmlCassettem"
  </code></pre>
  
  <p>And execution code:</p>
  
  <pre><code>CREATE PROCEDURE GenerateXmlCassettem
  AS
      DECLARE @fileName VARCHAR(50)
      DECLARE @sqlStr VARCHAR(1000)
      DECLARE @sqlCmd VARCHAR(1000)
  
      SET @fileName = 'C:\JAS\xml\CassetteList.xml'
      SET @sqlStr = 'select DevId as IdAutomate, id as idCassette, MedicineCode 
                     from jas_bis.dbo.Cassette 
                     where MedicineCode is not null for xml path'
  
  SET @sqlCmd = 'bcp "' + @sqlStr + '" queryout ' + @fileName + ' -w -T'
  
  EXEC xp_cmdshell @sqlCmd
  </code></pre>
  
  <p>Here you can find db table: Cassette that I use to excute stored procedure:</p>
  
  <pre><code>SELECT TOP (1000)
      [DevID], [Id],
      [Drawer], [Row], [Column],
      [Side], [DropDelay],
      [MedicineCode], [Priority],
      [RemainQty], [Unit],
      [Type], [MinQty], [ExpDT], [UseExpDT],
      [LotNO], [Barcode]
  FROM 
      [jas_bis].[dbo].[Cassette]
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Line 1<br>
    Incorrect syntax near 'D:'.</p>
  </blockquote>