title: My bcp hangs after creating an empty file
body: <p>I am trying to drop a file into a directory on the local machine (same machine running SQL Instance).  The content of the table I am trying to drop out is in xml format. </p>
  
  <p>ie.  table=xmlOutFiles, fieldName = xmlContent;  fieldName contains essentially varchar(max) data that is to become the xml file we need.</p>
  
  <p>When the bcp command is executed it seems to create the file in the @dest location, size = 0 bytes and then the process running from within SMSS just sits there waiting for something!</p>
  
  <p>I cannot do anything with that empty file, like delete it, unless I use task manager to kill the process "bcp.exe".</p>
  
  <p>I have tried multiple combinations of the bcp flags, etc.</p>
  
  <p>Running the bcp command from a system prompt, replacing the "@vars" seems to work but I really need it to be part of my SQL Trigger script and function.</p>
  
  <p>Assistance appreciated!!!!</p>
  
  <pre><code>Select @dest = (Select filename from xmlOutfiles)
  Select @cmd = 'bcp "Select xmlContent from ProcureToPay.dbo.XmlOutFiles" queryout '+@dest+' -x -w -T -S' + @@servername
  
  Exec xp_cmdshell @cmd       
  </code></pre>
  
  <p>I have tried executing with -T and -Uusername -Ppassword parameters, etc.</p>
  
  <p>This command works from the DOS prompt:</p>
  
  <pre><code>bcp "Select xmlContent from Procure.To.Pay.dbo.XmlOutFiles" queryout c:\temp\test.xml -x -w -T S&lt;myservernameHere&gt;
  </code></pre>