title: Invalid character in bcp
body: <p>I'm trying to call a BCP command from c#.I'm building the command within the c# code, and am getting an error. Here is the BCP command as I'm building it:</p>
  
  <pre><code>string.Format("bcp \"EXEC {0} {1}\" queryout \"{2}\" -c -t\"\0\" -S {3} -U {4} -P {5}", spName, filterList, path, server, user, password);
  </code></pre>
  
  <p>Here is the command after formatting:</p>
  
  <pre><code>"bcp \"EXEC StatisticsByType @Date='1/1/2013'\" queryout \"\\\\Server\\Folder\\MagicWords.txt\" -c -t\"\0\" -S server.com -U userName -P password"
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>{"Incorrect syntax near 'queryout'.\r\n'.' is an invalid name because it contains a NULL character or an invalid unicode character."}
  </code></pre>
  
  <p>I'm assuming it has something to do with how .Net is escaping the ". Would anyone know the proper way to pass those quotation marks around, or if thats even the issue?</p>
  
  <p><strong>EDIT:</strong> I ran the BCP command in question from the powershell ISE. It threw an "Unable to open BCP host data-file" error. So I changed the queryout server name to it's mapped network drive name, and It worked. However, doing the same thing in C# yielded no change.</p>