Filed under: ASP.NET, SQL, XML | Tags: ASP.NET C#, SQL Server, Stored Procedure, XML
CREATE PROCEDURE [dbo].[Student]
– Add the parameters for the stored procedure here
@studentlXML XML
AS
BEGIN
– SET NOCOUNT ON added to prevent extra result sets from
– interfering with SELECT statements.
SET NOCOUNT ON;
— Insert statements for procedure here
Declare @CountHandler int
Exec SP_XML_PrepareDocument @CountHandler OUTPUT,@studentlXML
INSERT INTO tblStudent –Table name where we have to save xml data
SELECT * FROM OPENXML(@CountHandler,”/friends/friend”,2)
WITH tblStudent
Exec SP_XML_RemoveDocument @CountHandler
END
END
NOTE: @studentlXML is a xml file can be passed as a string or file
friends is the parent node of xml and friend is a node under friends node, which will be excluded and rest nodes will be treated as column. Please note that node name should be exactly same as column name in table tblStudent
Leave a Comment so far
Leave a comment