Hello Madhivanan,DECLARE @s VARCHAR(8000)SELECT @s=''SELECT @s=@s + [UserName] + ','from TAB_ccsNetUsers where type = 'CN'SELECT @s = left(@s, Datalength(@s)-1)SELECT (@s) as UserNames;
I have the above one to get the usernames with commadelimit which will be specific to per record basis(getting usernames with comma delimit) for the insert into statementI want use the above one with the following stored procedure: Can you please help:CREATE PROCEDURE dbo.USP_SendEmailActions (@ModuleID int) ASINSERT INTO Tab_ccsNetEmailsum (toemail, body)Select u.Email, 'SentTo: ' + All usernames with comma delimit + char(13)+char(13)+ 'Project: ' + pj.projno + char(13)+char(13) + 'Contract: ' + ct.contractno + char(13) +char(13) + 'Due Date: ' + CONVERT(varchar(10),a.DueDate,101) as bodyfrom tab_ccsnetactions a, tab_ccsnetprograms pg, tab_ccsnetprojects pj,tab_ccsnetcontracts ct, TAB_ccsNetUsers u, tab_ccsnetcn m where a.ModuleRecordID = m.cnid anda.assignedto = u.UserID andm.progid = pg.progid and m.projid = pj.projid andm.contractid = ct.contractid anda.modulerecordid = @ModuleIDGO
Thank you very much.