declare @ownerId int = ; declare @ownerType varchar(3) = ; with reasons as ( select reasonId, reasonName, sortRank from tbl_CRM_OtherReasons with (nolock) where ownerId = @ownerId and ownerType = @ownerType ) #forJSON( 'reasons', attributes.datastore, 'sortRank' )#