declare @ownerId int = ; declare @ownerType varchar(3) = ; declare @groupId int = ; with members as ( select m.fspro_userId, m.email, m.firstName, m.lastName, m.staffMember, m.firstName + ' ' + m.lastName as fullName from tbl_SEC_MemGrpLink mgl with (nolock) inner join tbl_fspro_members m with (nolock) on m.fspro_userId = mgl.fspro_userId where m.ownerId = @ownerId and m.fsl_tablecode = @ownerType and m.loginEnabled = 1 and mgl.groupId = @groupId ) #forJSON( 'members', attributes.dataStore, 'fullName' )#