Forum Replies Created

Viewing 15 posts - 61 through 75 (of 140 total)

  • RE: XML Shred to tabular data

    Here is a quick example to shred that xml to a flat table:

    DECLARE @xml XML

    SET @xml = '<employees>

    <employee>

    <emp_id>1</emp_id>

    <emp_name>Bob</emp_name>

    <skills>

    <skills_id>1</skills_id>

    <skills_id>tsql</skills_id>

    <skills_id>2</skills_id>

    <skills_id>SSRS</skills_id>

    <skills_id>3</skills_id>

    <skills_id>SSAS</skills_id>

    <skills_id>4</skills_id>

    <skills_id>SSIS</skills_id>

    <skills_id>5</skills_id>

    <skills_id>Replication</skills_id>

    </skills>

    </employee>

    <employee>

    <emp_id>2</emp_id>

    <emp_name>Frank</emp_name>

    <skills>

    <skills_id>1</skills_id>

    <skills_id>tsql</skills_id>

    <skills_id>2</skills_id>

    <skills_id>SSRS</skills_id>

    <skills_id>3</skills_id>

    <skills_id>SSAS</skills_id>

    </skills>

    </employee>

    </employees>

    '

    SELECT e.c.value('(emp_id)[1]', 'int') AS emp_id

    , e.c.value('(emp_name/text())[1]', 'varchar(50)') AS emp_name

    , s.c.value('(.)[1]', 'varchar(50)') AS skills_id

    FROM...

  • RE: Nested XML/CDATA ...

    Hi,

    Personally, if I was to approach this from the SQL server side of things, I would do something like the following. It isn't pretty, but it works and I hope...

  • RE: Relational Model versus XML

    Hugo Kornelis (1/24/2013)


    I think the correct answer should be worded slightly differently: "Either one can be appropriate" (italics used to emphasize changed part).

    If forced to make a choice based on...

  • RE: Another XML to tabular question

    hb21l6 (1/23/2013)


    Thank you arthurolcot very very much! That did exactly what I was looking for.

    Many thanks

    David

    No problem.. Thanks for the feedback.

  • RE: Another XML to tabular question

    Hi,

    I think you are very close, does this updated final query do what you need it to do or get you closer?

    select

    C.value('(Customers/CustomerID)[1]','INT') as CusID,

    C.value('(Customers/ContactName)[1]','varchar(50)')...

  • RE: XML: Adjust Element Positioning

    Hi, One way of approaching it could be to use a CTE + sub query similar to this:

    ;WITH xCTE (CoveredEntity) AS

    (

    SELECT DISTINCT CoveredEntity

    FROM @t

    )

    SELECT CoveredEntity AS '@Name',

    (

    SELECT CoverageLoser AS...

  • RE: XML Shredding

    As Ray mentions, the xml methods are perfect for this.. here is an example based on your xml

    DECLARE @xml XML

    SET @xml = '<server name="Server1">

    <log>

    <logItem type="LogDate">

    <value string="2012/12/15" />

    </logItem>

    <logItem type="error">

    <value string="File not...

  • RE: import and shred xml file to sql 2008 table (openrowset)

    No problem....thanks for the feedback

  • RE: import and shred xml file to sql 2008 table (openrowset)

    Hi,

    I think the main thing that you was missing was the namespace declaration. I have also made a couple of minor alterations, namely the cross apply and removing the .query()...

  • RE: capturing multiple attributes from node

    Hi,

    I would use the newer XML functions rather then the old OPENXML. Syntax wise you could probably do this in a couple of ways, but here is one that I...

  • RE: SQL

    Lokesh Vij (11/30/2012)


    Stewart "Arturius" Campbell (11/30/2012)


    Koen Verbeeck (11/30/2012)


    Got it wrong because you can update or delete rows in the primary tables if you specify ON CASCADE options.

    Next time do more...

  • RE: if you're using typed xml in sql server 2008, does the xml you store need to have every node that's in the XSD?

    In other words, as long as the xml document conforms to the XSD, you can have as many or as few nodes as necessary.

    That is the crucial thing, as long...

  • RE: Setting the value of an XML attribute using a relational variable

    If i understand you correctly, you have an xml instance as a string which you want to assign directly to an xml variable whilst at the same time, populating some...

  • RE: Returning multiple rows from XML

    grovelli-262555 (11/2/2012)


    Are there any books that explain syntax such as $x or //EXPR

    ?

    Hi grovelli,

    $x is a variable within a flwor statement. You can begin to learn about flwor statements...

  • RE: Returning multiple rows from XML

    Jeff Moden (10/31/2012)


    Nice job, Arthur.

    No reflection on your fine code. Just an observation about XML. I'm absolutely amazed at how expensive this type of XML processing actually is.

    Hi...

Viewing 15 posts - 61 through 75 (of 140 total)