DECLARE @s VARCHAR(100)SET @s='a,b,c,dd,ee,f,aa,a,aa,f'SELECT b.v FROM (SELECT CAST('<r>' + REPLACE(@s,',','</r><r>') + '</r>' AS XML) x) a CROSS APPLY (SELECT v=t.x.value('.','VARCHAR(10)') FROM a.x.nodes('//r') AS t(x) ) b
value方法中的'.'是什么意思?
SQL code
DECLARE @myDoc xmlDECLARE @ProdID intSET @myDoc = '<Root><ProductDescription ProductID="1" ProductName="Road Bike"><Features> <Warranty>1 year parts and labor</Warranty> <Maintenance>3 year parts and labor extended maintenance is available</Maintenance></Features></ProductDescription></Root>'SET @ProdID = @myDoc.value('(/Root/ProductDescription/@ProductID)[1]', 'int' )SELECT @ProdID