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
Post a Comment