--getting xml fro relational data
Select * from Customer
For xml raw,
Select * from Customer
For xml raw ('customer'),
elements, root('customers')
--xml as a data type
Create table memo
(
MemoID int identity(1,1) Primary key,
MemoXml xml
)
Insert into memo(MemoXml)
Values (
'
Dr. Davd Jones
Edith Smith
3/2/2009
Magazine Sales
Magazine sales really suck right now. I suggest
we call an executive meeting to see what we can do
')
Insert into memo(MemoXml)
Values (
'
Dr. Robert Larson
Edith Smith
3/2/2009
Magazine Sales
We have two magazines that have never
sold a copy I think we should drop them from our
list
')
Select * from Memo
--xpath/xquery
Select
MemoXml.query('//head/date') as "Date",
MemoXml.query('//head/about') as subjects
from memo