title: Error in using xp_cmdshell to read XML contents
body: <p>I need to read the contents of a <code>XML</code> file using <code>SQL</code> commands. I use <code>xp_cmdshell</code> to read the file and insert all contents into temporary table. </p>
  
  <p>this is my stored procedure:</p>
  
  <pre><code>ALTER PROCEDURE ReadingXMLTest (@FileName VARCHAR(255))
  AS
  BEGIN
      DECLARE @ExecCmd VARCHAR(255)
      SET @FileName = 'C:\PrivateData\EmployeesInfo.xml';
      CREATE TABLE #tempXML(PK INT NOT NULL IDENTITY(1,1), ThisLine VARCHAR(255))
      SET @ExecCmd= 'type' + @FileName;
      INSERT INTO #tempXML EXEC master.dbo.xp_cmdshell @ExecCmd;
  END 
  </code></pre>
  
  <p>But I get this error- </p>
  
  <blockquote>
    <p>The filename, directory name, or volume label syntax is incorrect. </p>
  </blockquote>
  
  <p>I am sure that the specified file exists in the directory of the machine where SQL Server is running. File name, directory name, volume label everything is correct. But why?</p>
  
  <p>Please help me. I tried for many times.</p>