C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




using xml file I want to create table and insert data into sql server


Posted Date: 28 Aug 2008      Total Responses: 3

Posted By: subbarayudu       Member Level: Silver     Points: 1


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




Responses

Author: vipul    28 Aug 2008Member Level: DiamondRating:     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 2008Member Level: SilverRating:     Points: 0
u wanted to insert data throw xml



Author: subbarayudu    28 Aug 2008Member Level: SilverRating:     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.



Post Reply
You must Sign In to post a response.
Next : Date Difference in oracle
Previous : Transfer Error Messages Tasks
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

it help desk

Contact Us    Privacy Policy    Terms Of Use