Reputation: 11
I need to write a basic t-sql function f that receives the following parameters:
(Id int, CustomerId int, Delay int)
and creates, for f(1, 125, 32), the following xml, to be later inserted into a xml column in a table:
<content>
<column name="Id">1</column>
<column name="CustomerId">125</column>
<column name="Delay">125</column>
</content>
Any ideas on how to attack the problem?
Upvotes: 1
Views: 98
Reputation: 117510
select *
from (values
(@Id, 'Id'), (@CustomerId, 'CustomerId'), (@Delay, 'Delay')
) as a([@Name], [text()])
for xml path('column'), root('content')
Upvotes: 1