with data as ( SELECT s.stateID, s.state, s.stateFull, c.countryId, c.country FROM tbl_UT_States s with (nolock) INNER JOIN tbl_UT_Countries c with (nolock) ON c.countryId = s.countryId and c.countryId = #val( attributes.datastore.objectParams.countryId )# ) #forJSON( 'data', attributes.datastore, 'state' )#