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 SELECT @NamesList

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

Show Correct Answer


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response