Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert data from XML column to a temp table

Author  Topic 

guranbaksh@hotmail.com
Starting Member

1 Post

Posted - 2009-03-17 : 14:57:57
Hi All,

I am fairly new to XML. I have the following scenario
DECLARE @doc xml


SELECT @doc = '<Team name="Braves">
<Players>
<Pitcher name="John Smoltz" role="Closer"/>
<Pitcher name="Russ Ortiz" role="Starter" />
<ThirdBase name="Chipper Jones"
role="Starter" bats="switch"/>
</Players>
</Team> '


SELECT @doc.query('.')

My question is, is there a way to create a table on the fly (not knowing what column names or data type may be present in the xml)?

So something like: select * into #test from @doc.query(???)

Thanks in advance for your help.
   

- Advertisement -