declare @ownerId int = ; declare @ownerType varchar(3) = ; declare @campaignGroupAttrTypeId int = ; with data as ( select a.attrId as campaignGroupId, a.attrDescription as campaignGroup from tbl_ORG_Attributes a with (nolock) where a.ownerId = @ownerId and a.fsl_tablecode = @ownerType and a.attrTypeId = @campaignGroupAttrTypeId ) #forJSON( 'data', attributes.datastore, 'campaignGroup' )#