http://topic.csdn.net/u/20090215/15/96eb6d83-c785-454f-9562-ab558bfcc040.html
--列和变量查询
declare @xml xml,@id int
set @xml ='<root><r id="1">a</r><r id="2">b</r></root>'
set @id=2
select
colname=@xml.value('(/root/r[@id=sql:column("id")])[1]','varchar(100)'),
variablename=@xml.value('(/root/r[@id=sql:variable("@id")])[1]','varchar(100)')
from(select id=1)t