I would look at the following helpful posts http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=140334&SearchTerms=query,xmlYou also need to fix up your xml tags.declare @xml as xmlSET @xml = '<PDI_Approval_Message><header><SourceSystem value ="WF" Name ="Workforce"></SourceSystem><TransactionType value="WF_TS" Name="WF-TimeSheet" ></TransactionType><RequestType value ="Submit" Name="Action"></RequestType><SubmittedOn Value="02/06/2010" Name=""></SubmittedOn><SubmittedBy Value="pdi/vmuser3" Name="hannok"></SubmittedBy></header><Transactions><Transaction ID = " WF_b738b9b1-5cb1-48e3-98cd-044065d4ac22"><Attributes><Attribute value = "0625" Name = "Emp_ID"/><Attribute value = "03/06/2010" Name = "Week_Ending"/><Attribute value = "0034" Name = "Site_ID"/><Attribute value = "15" Name = "TotalHrs"/><Attribute value = "10" Name = "Total_Overtime"/></Attributes><Attachments><Attachment value = "/test/file.doc" Name = "timesheetdocument"/><Attachment value = "/test/file1.doc" Name = "approvalletter"/></Attachments></Transaction ><Transaction ID = " WF_728d1ec7-de8f-4575-86cb-3cbb37b133a4"><Attribute value = "06251" Name = "Emp_ID"/><Attribute value = "03/06/2010" Name = "Week_Ending"/><Attribute value = "0034" Name = "Site_ID"/><Attribute value = "20" Name = "TotalHrs"/><Attribute value = "10" Name = "Total_Overtime"/></Transaction ><Transaction ID = " WF_7ae6ec19-c677-49a1-b87c-5887d26889ba"><Attribute value = "06252" Name = "Emp_ID"/><Attribute value = "03/06/2010" Name = "Week_Ending"/><Attribute value = "0034" Name = "Site_ID"/><Attribute value = "30" Name = "TotalHrs"/><Attribute value = "10" Name = "Total_Overtime"/></Transaction ></Transactions></PDI_Approval_Message>'CREATE TABLE Header (HeaderID int IDENTITY(1,1), SourceSystemValue varchar(100), SourceSystemName varchar(100), TransactionTypeValue varchar(100), TransactionTypeName varchar(100), RequestTypeValue varchar(100), RequestTypeName varchar(100))--following table variable can hold the headerid in case you need it for other tabledeclare @header table(HeaderID int)INSERT INTO Header OUTPUT inserted.HeaderID INTO @header select a.b.value('./SourceSystem[1]/@value','varchar(100)') as SourceSystemValue, a.b.value('./SourceSystem[1]/@Name','varchar(100)') as SourceSystemName, a.b.value('./TransactionType[1]/@value','varchar(100)') as TransactionTypeValue, a.b.value('./TransactionType[1]/@Name','varchar(100)') as TransactionTypeName, a.b.value('./RequestType[1]/@value','varchar(100)') as RequestTypeValue, a.b.value('./RequestType[1]/@Name','varchar(100)') as RequestTypeNameFROM @xml.nodes('/PDI_Approval_Message/header')a(b)SELECT * FROM @Header
If you don't have the passion to help people, you have no passion