How to pass XML from C# to a stored procedure in SQL Server 2008?

后端 未结 4 956
春和景丽
春和景丽 2020-11-30 06:55

I want to pass xml document to sql server stored procedure such as this:

CREATE PROCEDURE BookDetails_Insert (@xml xml)

I want compare some

4条回答
  •  感情败类
    2020-11-30 06:57

    As stated in http://support.microsoft.com/kb/555266, you need to pass xml data as NText.

    You can query an XML variable as follows:

    DECLARE @PeopleXml XML
        SET @PeopleXml = '
        
        James
        28
        
        
        Jane
        24
        
        '
    --  put [1] at the end to ensure the path expression returns a singleton.
    SELECT p.c.value('Person[1]/Name[1]', 'varchar(50)')
    FROM @PeopleXml.nodes('People') p(c) -- table and column aliases
    

提交回复
热议问题