Thursday, June 4, 2009

declare @samplexml xml

declare @samplexml xml
set @samplexml ='<ROOT><STUDENT NAMES  = "CHAKRI" MARKS= "23" /><STUDENT NAMES  = "PRASANNA" MARKS = "65" /></ROOT>'
declare @pointer int
execute sp_xml_preparedocument @pointer output, @samplexml

select  

NAMES,MARKS

from
openxml(@pointer,'/ROOT/STUDENT')
WITH(NAMES VARCHAR(25),MARKS INT)