Help ! XML problem

  • Dear,

    I don't know how to handle this XML problem :

    Table "Group_Info"

    Group Group_Members

    101

    201

    301

    Table "Members"

    Member_ID Member_Name

    1011 Name_1011

    1012 Name_1012

    1013 Name_1013

    2011 Name_2011

    2012 Name_2012

    3011 Name_3011

    3012 Name_3012

    3013 Name_3013

    I want to have the following results :

    101

    201

    301

    I can only write :

    SELECT BookmarkRestaurant.RBCategoryIds.query('

    element IDs

    {

    element ID { string((/IDs/ID)[1])},

    element Name { sql:column("RBCategory.Name") },

    element UserId { sql:column("RBCategory.UserId") }

    }

    ') AS Result,

    BookmarkRestaurant.RestaurantId, BookmarkRestaurant.UserId,

    BookmarkRestaurant.CreateTime,

    RBCategory.RBCategoryId, RBCategory.Name, RBCategory.UserId

    FROM BookmarkRestaurant, RBCategory

    WHERE BookmarkRestaurant.RBCategoryIds.value('(/IDs/ID)[1]','int')

    = RBCategory.RBCategoryId

    (Different Table name and field name)

    But I have to hard code : eg. value('(/IDs/ID)[1]',

    How can I make a sp or SQL statement which can scan all the node of each row and then scan all the rows automatically ?

  • Please, post proper DDL, sample data and expected results.

    See this article for details:

    http://www.aspfaq.com/etiquette.asp?id=5006

    ML

    ---
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • I want to have the following results :

    101

    201

    301

    I believe some of your tags were stripped. If you are trying to post XML use brackets instead.

    e.g.

    [tag] data [/tag]

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply