• The nodes() method of the xml datatype makes this straight forward.

    😎

    DECLARE @X XML

    SET @X = '<root>

    <production.Categories categoryid="1" categoryname="Beverages" description="Soft drinks, coffees, teas, beers, and ales" />

    <production.Categories categoryid="2" categoryname="Condiments" description="Sweet and savory sauces, relishes, spreads, and seasonings" />

    <production.Categories categoryid="3" categoryname="Confections" description="Desserts, candies, and sweet breads" />

    <production.Categories categoryid="4" categoryname="Dairy Products" description="Cheeses" />

    <production.Categories categoryid="5" categoryname="Grains/Cereals" description="Breads, crackers, pasta, and cereal" />

    <production.Categories categoryid="6" categoryname="Meat/Poultry" description="Prepared meats" />

    <production.Categories categoryid="7" categoryname="Produce" description="Dried fruit and bean curd" />

    <production.Categories categoryid="8" categoryname="Seafood" description="Seaweed and fish" />

    <production.Categories categoryid="9" categoryname="Beer" description="Budweiser" />

    <production.Categories categoryid="10" categoryname="Liquor" description="Captain Morgan" />

    </root>'

    SELECT

    RO.CT.value('@categoryid','INT') AS categoryid

    ,RO.CT.value('@categoryname','NVARCHAR(250)') AS categoryname

    ,RO.CT.value('@description','NVARCHAR(2048)') AS description

    FROM @X.nodes('root/production.Categories') AS RO(CT);

    Output

    categoryid categoryname description

    ----------- -------------------- ------------------------------------------------------------

    1 Beverages Soft drinks, coffees, teas, beers, and ales

    2 Condiments Sweet and savory sauces, relishes, spreads, and seasonings

    3 Confections Desserts, candies, and sweet breads

    4 Dairy Products Cheeses

    5 Grains/Cereals Breads, crackers, pasta, and cereal

    6 Meat/Poultry Prepared meats

    7 Produce Dried fruit and bean curd

    8 Seafood Seaweed and fish

    9 Beer Budweiser

    10 Liquor Captain Morgan