• I think this will get you started:

    DECLARE @XML XML = '<?xml version="1.0" encoding="UTF-8"?>

    <sessions accountId=''48152'' startDate=''2012-05-27'' startTime=''00:00:00'' endDate=''2012-05-28'' endTime=''00:00:00''>

    <session applicationId=''357627'' applicationName=''app1'' startTime=''00:48:54'' startDate=''2012-05-27'' type=''abc'' direction=''outbound'' durationMinutes=''0.43'' token=''113ddd5999257543963a760789fc12344f27cb0bcc519f0ce6d3a907fccb0d56361c4e3151c3780c35c752cb'' bridged=''false'' callerId=''1234567890'' sessionId=''86c368af24d7eab2a84ec6660704f3d4'' connectionId=''0''>

    <outboundDialString dialString=''11234567890''/>

    </session>

    <session applicationId=''112549'' applicationName=''app2'' startTime=''01:14:33'' startDate=''2012-05-27'' type=''abc'' direction=''inbound'' durationMinutes=''2.73'' calledId=''1234567890'' bridged=''false'' callerId=''1234567890'' sessionId=''7d35636be123418f93fe638a9bac78d9'' connectionId=''0''/>

    <session applicationId=''357627'' applicationName=''app3'' startTime=''00:48:54'' startDate=''2012-05-27'' type=''abc'' direction=''outbound'' durationMinutes=''0.43'' token=''113ddd5999257543963a760789fc12344f27cb0bcc519f0ce6d3a907fccb0d56361c4e3151c3780c35c752cb'' bridged=''false'' callerId=''1234567890'' sessionId=''86c368af24d7eab2a84ec6660704f3d4'' connectionId=''0''>

    <outboundDialString dialString=''11234567890''/>

    </session>

    <session applicationId=''357627'' applicationName=''app4'' startTime=''00:48:54'' startDate=''2012-05-27'' type=''abc'' direction=''outbound'' durationMinutes=''0.43'' token=''113ddd5999257543963a760789fc12344f27cb0bcc519f0ce6d3a907fccb0d56361c4e3151c3780c35c752cb'' bridged=''false'' callerId=''1234567890'' sessionId=''86c368af24d7eab2a84ec6660704f3d4'' connectionId=''0''>

    <outboundDialString dialString=''11234567890''/>

    </session>

    <session applicationId=''357627'' applicationName=''app5'' startTime=''00:48:54'' startDate=''2012-05-27'' type=''abc'' direction=''outbound'' durationMinutes=''0.43'' token=''113ddd5999257543963a760789fc12344f27cb0bcc519f0ce6d3a907fccb0d56361c4e3151c3780c35c752cb'' bridged=''false'' callerId=''1234567890'' sessionId=''86c368af24d7eab2a84ec6660704f3d4'' connectionId=''0''>

    <outboundDialString dialString=''11234567890''/>

    </session>

    <session applicationId=''357627'' applicationName=''app6'' startTime=''00:48:54'' startDate=''2012-05-27'' type=''abc'' direction=''outbound'' durationMinutes=''0.43'' token=''113ddd5999257543963a760789fc12344f27cb0bcc519f0ce6d3a907fccb0d56361c4e3151c3780c35c752cb'' bridged=''false'' callerId=''1234567890'' sessionId=''86c368af24d7eab2a84ec6660704f3d4'' connectionId=''0''>

    <outboundDialString dialString=''11234567890''/>

    </session>

    </sessions>' ;

    SELECT @XML.value('(/sessions/@accountId)[1]', 'int') AS AccountID,

    @XML.value('(/sessions/@startDate)[1]', 'date') AS StartDate,

    @XML.value('(/sessions/@startTime)[1]', 'time') AS StartTime,

    @XML.value('(/sessions/@endDate)[1]', 'date') AS EndDate,

    @XML.value('(/sessions/@endTime)[1]', 'time') AS EndTime ;

    SELECT Ssn.value('(/session/@applicationId)[1]', 'int') AS ApplicationID

    FROM (SELECT S.s.query('.') AS Ssn

    FROM @XML.nodes('/sessions/session') AS S (s)) AS SSnes ;

    What I've done is turn it into a consumable XML format by assigning it to a typed variable. You can do the same with a column in table.

    Then I pulled the outer data, relevant to the "sessions" level. That would go in one table (assuming normalized database design). Then the inner data can be queried, you just need to add the rest of the columns following my example. You will probably also need the AccountID in that table, which is easy enough to get into it by adding that piece from the first query to the second query, if you need it.

    Does that help?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon