Reputation: 2438
I have a table which contains HTML tag . I just want to create a HTML FORM using this table is HTML FOrmat for eg.
ID Tags
-- ----
1 Html
2 Head
3 Title
4 Meta
5 Body
6 Font
Result should be
ID HTML
-- ------------------------------------------------------------------------------------
1 <Html> <Head> <Title></Title> <Meta></Meta> </Head><Body> <Font></Font></Body</Html>
Upvotes: 0
Views: 206
Reputation: 15673
declare @t table(id int, tags varchar(50))
insert into @t values
(1, 'Html'),
(2, 'Head'),
(3, 'Title'),
(4, 'Meta'),
(5, 'Body'),
(6, 'Font')
;with Tags1 as
(
select xml1 = (select '<' + tags + '>' from @t for xml path (''))
)
,Tags2 as
(
select xml2 = (select '</' + tags + '>' from @t order by id desc for xml path (''))
)
select replace(replace(Tags1.xml1 + Tags2.xml2,'<','<'),'>','>')
from Tags1, Tags2
Upvotes: 1