declare @ownerId int = ; declare @ownerType varchar(3) = ; with classifications as ( select c.classificationId, c.name, c.description, c.sortRank, c.abbreviation from tbl_OPR_Classifications c with (nolock) where ownerId = @ownerId and ownerType = @ownerType ) #forJSON( 'classifications', attributes.datastore, 'sortRank' )#