sql server - accessing value from SQL parameter to use it for an XML attribute -


i trying build xml using parameter value attribute.

declare @price int =100  declare @xml xml = '<product discountprice= "{sql:variable("@price")}"   />'  select @xml 

i following error.

msg 9410, level 16, state 1,
xml parsing: whitespace expected'

what missing here?

i believe sql:variable used within .query() calls. how can create snippet of xml using variable:

declare @price int =100 declare @xml xml;  set @xml = (select [@discountprice] = @price xml path('product'));  select @xml 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -