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'


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

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

Show Correct Answer


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response