Brauchen Sie Hilfe bei SQL XML Query

Ich habe fast keine Erfahrung mit der Abfrage von XML-data mit T-SQL. Angesichts der unten gezeigten XML, wie würde ich den 'Sub_ID' Wert extrahieren?

<MESSAGE LABEL = "IVSWEEP" > <H SIMULATOR = "54355" COMMENT = "" OPERATOR = "Operator" SUB_ID = "090617041199" PROCESS_CD = "AHIPOT" DATE_TIME = "6/19/2009 11:57:35 AM" TMOD = "23.05" TCOR = "23.05" <DP = "0" I = "0" V = "0" /> <DP = "1" I = "1.250854" V = "0" /> <DP = "2" I = "1.251904" V = "4.212341" /> <DP = "3" I = "1.24895" V = "7.517395" /> </H> </MESSAGE> 

Hier ist ein path. Ihr XML war ungültig. Fehlt ein > um <H zu beenden.

 declare @xml xml = '<MESSAGE LABEL = "IVSWEEP" > <H SIMULATOR = "54355" COMMENT = "" OPERATOR = "Operator" SUB_ID = "090617041199" PROCESS_CD = "AHIPOT" DATE_TIME = "6/19/2009 11:57:35 AM" TMOD = "23.05" TCOR = "23.05"> <DP = "0" I = "0" V = "0" /> <DP = "1" I = "1.250854" V = "0" /> <DP = "2" I = "1.251904" V = "4.212341" /> <DP = "3" I = "1.24895" V = "7.517395" /> </H> </MESSAGE>' declare @T table (Col1 xml) insert into @T values(@xml) insert into @T values(@xml) insert into @T values(@xml) select mhvalue('@SUB_ID', 'varchar(50)') from @T cross apply Col1.nodes('MESSAGE/H') as m(h)