Setting a variable equal to a variable in SQL Server -


i'm working on problem colleagues impossible. there xml in our database , want able take single attributes xml , set them equal variables work with. code far (that doesn't work).

    declare @mytext varchar(10)      declare @myxml xml     set @myxml = '     <ns0:testxml xmlns:ns0="http://test.com">     <testvalue>11</testvalue>     </ns0:testxml>'      set @mytext =     (        ;with xmlnamespaces ('http://test.com' ns0)        set @mytext =         (            select                 a.bo.value('(/ns0:testxml2[1]/testxml3)[1]','int') [number]            @myxml.nodes('ns0:testxml') a(bo)        )    ) 

any appreciated, thank you. if logic off how sql works xml, please don't hesitate educate me.

how's this, returns 11 provided xml want assume:

declare @mytext varchar(10)  declare @myxml xml set @myxml = ' <ns0:testxml xmlns:ns0="http://test.com"> <testvalue>11</testvalue> </ns0:testxml>'  ;with xmlnamespaces ('http://test.com' ns0)     select @mytext =         a.bo.value('(/ns0:testxml)[1]','int')      @myxml.nodes('ns0:testxml') a(bo)  select @mytext [theimpossiblevalue] 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -