declare @ownerId int = ; declare @ownerType varchar(3) = ; with priorities as ( select cp.priorityId, cp.priorityCode, cp.profileRequirementConfig, cp.callFreqThresholdWks from tbl_OPR_CLientPriorities cp with (nolock) where ownerId = @ownerId and ownerType = @ownerType and active = 'Y' ) #forJSON( 'priorities', attributes.datastore, 'priorityCode' )#