Get Column Value into Comma Sepreted Using Coalesce() in SQL Server

First of all create table and insert record in it.
  1. CREATE TABLE [dbo].[EMP_MAST](  
  2. [EMP_CODE] [varchar](10) NULL,  
  3. [NAME] [varchar](10) NULL)  
  4.   
  5. INSERT INTO EMP_MAST (EMP_CODE,NAMEVALUES('NJS','Nikhil')  
  6. INSERT INTO EMP_MAST (EMP_CODE,NAMEVALUES('BNS','ABC')  
After that run this query.
  1. Declare @Str VArchar(Max)  
  2. SELECT @Str =Coalesce(@Str +','+ EMP_CODE,EMP_CODE)FROM [dbo].[EMP_MAST]  
  3.   
  4. select @Str  
Output

NJS,BNS