How to Pass XML paramter in T-SQL?

declare @PersonInfo xml = '<Person>
<Info Name ="Karthik" Age="25" />
<Info Name ="Arun" Age="25" />
<Info Name ="Vaduvoor Kumar" Age="25" />
</Person>'


dECLARE @idoc int
EXEC sp_xml_preparedocument @idoc OUTPUT,@PersonInfo --xmlfield

SELECT
Name,Age into #temp
FROM OPENXML
(@idoc, '/Person/Info',1)
WITH (Name varchar(50), Age int)

EXEC sp_xml_removedocument @idoc

select * from #temp

drop table #temp

No comments: