I need to read the contents of a XML
file using SQL
commands. I use xp_cmdshell
to read the file and insert all contents into temporary table.
this is my stored procedure:
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
But I get this error-
The filename, directory name, or volume label syntax is incorrect.
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?
Please help me. I tried for many times.