Is it possible to bind HTML templates with JSON data dynamically without using a loop in sql server?
DECLARE @json NVARCHAR(MAX) = '[{"name": "John Doe", "age": 30}, {"name": "Jane Smith", "age": 25}, {"name": "Bob Johnson", "age": 35}]'
DECLARE @htmlTemplate NVARCHAR(MAX)
SET @htmlTemplate = N'
<h1>Name: ' + (SELECT JSON_VALUE(@json, '$[0].name')) + '</h1>
<p>Age: ' + (SELECT JSON_VALUE(@json, '$[0].age')) + '</p>
'
-- Insert the HTML template into the 'templatedemo' table
INSERT INTO templatedemo (template) VALUES (@htmlTemplate)