with data as ( select territoryId, name as territoryName, territoryPath from tbl_TER_Territories with (nolock) where ownerId = and fsl_tablecode = and territoryId in ( ) ) #forJSON( 'data', attributes.datastore, 'territoryPath' )#