What will be the output of

declare @t table(names varchar(MAX))
insert into @t
select 'Ram' union all
select 'Shyam' union all
select 'Jadhu' union all
select 'Madhu' union all
select 'NULL'


DECLARE @NamesList VARCHAR(8000);
SELECT @NamesList =
COALESCE(@NamesList + ', ', '') + CAST(names AS varchar(20))
FROM @t
SELECT CombinedResult = @NamesList

 Posted by Rajnilari2015 on 11/7/2015 | Category: Sql Server Interview questions | Views: 1525 | Points: 40
Select from following answers:
  1. Ram, Shyam, Jadhu, Madhu
  2. Madhu,Jadhu,Shyam,Ram
  3. NULL
  4. Ram, Shyam, Jadhu, Madhu, NULL
  5. All Above

Show Correct Answer


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response