declare @ownerId int = ; declare @ownerType varchar(3) = ; with data as ( select failureReasonId, failureReason, sortRank from tbl_CRM_AuditFailureReasons with (nolock) where ownerId = @ownerId and ownerType = @ownerType ) #forJSON( 'data', attributes.datastore, "sortRank, failureReason" )#