DECLARE @TempTable TABLE
(
_tagName VARCHAR(25),
_value1 VARCHAR(50),
_value2 VARCHAR(50)
)
Declare @valuation varchar(25)
SET @valuation = '123'
INSERT @TempTable SELECT 'TEST', 'FScore', '123456789'
INSERT @TempTable SELECT 'TEST', 'EstimatedMarketingTime', '123512'
SELECT (SELECT
_value1 AS [_Name],
_value2 AS [_Value],
@valuation
FROM @TempTable AS A WHERE _TagName = 'TEST'
FOR XML PATH('TEST'), TYPE).query('
<TEST PropertyAppraisedValueAmount="{ sql:variable("@valuation") }">
{
for $TEST in /TEST
return
<Key _Name="{data($TEST/_Name)}" _Value="{data($TEST/_Value)}"></Key>
}
</TEST>')
GO
|