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 - NULL

 Posted by Rajnilari2015 on 11/7/2015 | Category: Sql Server Interview questions | Views: 564 | Points: 40
Select from following answers:
  1. Ram, Shyam, Jadhu, Madhu
  2. Madhu,Jadhu,Shyam,Ram
  3. NULL
  4. Error: The data types varchar and NULL are incompatible in the subtract operator.
  5. All Above

Show Correct Answer


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response