I written below procedure for my query but it is displaying error Msg 213, Level 16, State 7, Procedure xp_cmdshell, Line 1 Insert Error: Column name or number of supplied values does not match table definition.
I have xml file name is emp.xml there what i written in xml file same as in procedure there is no diffenrence in case sensitive also. plz.. tell me urgent requirement
DECLARE @FileName varchar(255) DECLARE @ExecCmd VARCHAR(255) DECLARE @y INT DECLARE @x INT DECLARE @FileContents VARCHAR(8000)
CREATE TABLE #tempXML( Accno int NOT NULL, Names varchar(50), Balance decimal(18, 0) NOT NULL, Location varchar(50) )
SET @FileName = 'E:\Rayudu\emp.xml' SET @ExecCmd = @FileName SET @FileContents = ''
INSERT INTO #tempXML EXEC master.dbo.xp_cmdshell @ExecCmd SELECT @y = count(*) from #tempXML
SET @x = 0 WHILE @x <> @y BEGIN SET @x = @x + 1 SELECT @FileContents = @FileContents + Names + Balance + Location from #tempXML WHERE Accno = @x END
--SELECT @FileContents as FileContents --DROP TABLE #tempXML
|
| Author: vipul 28 Aug 2008 | Member Level: Diamond | Rating: Points: 6 |
hi, i used this way to insert xml dat into sql table DECLARE @idoc INT declare @XmlFile xml
SET @XmlFile = 'Your XML Data'
EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlFile, @xmlnamespace
INSERT INTO [Table] (OperatorsName ,Telephone ,Date, Transcript) SELECT OperatorsName, Telephone, Date, Transcript, FROM OPENXML(@idoc, '/Calls_Log/Call',2) WITH( OperatorsName VARCHAR(50), Telephone VARCHAR(50), Date VARCHAR(50), Transcript VARCHAR(50) )
vipul, http://dongavipul.blogspot.com
|
| Author: Reddy 28 Aug 2008 | Member Level: Silver | Rating: Points: 0 |
u wanted to insert data throw xml
|
| Author: subbarayudu 28 Aug 2008 | Member Level: Silver | Rating: Points: 2 |
I dont want to write xml data inside procedure , I want to use the xml file ,i have to specify the path of the xml file in the procedure.
|