Combine multiple rows into one

1)

declare @NameList varchar(100)
select @NameList= isnull(@NameList+’, ‘,”)+CityName from lkpUAECity
select @NameList

2)

SELECT LEFT(l.list,LEN(l.list)-1)
FROM
(
SELECT CityName + ‘,’ AS [text()]
FROM lkpUAECity
FOR XML PATH(”))l(list)

Advertisements