Regardless of the year of the Jeep, if your Transfer-Case is from a 97, you use a gear for a 97.
Should be the short gear.
There is a write up in the FAQ section for changing the gear.
Edit: I'm sorry. After reading that again, I am no longer sure because I don't remember if the 92 wasn't a cable setup - which used the long gear IIRC. You may end up using the 92 setup.
It should still fit. I believe the gear length was because of the sensor. The gear is in the sender side anyway and doesn't require dripping the TC to change.
Nope, not quite. Close though.
You use the speedo gear that goes with your VSS or speedo cable drive pickup assembly. Either one will bolt into any year transfer case.
Cable driven (90 and earlier) XJs/MJs - long shaft speedo
Dakotas until 93 - long shaft
YJs until 93 - long shaft
XJs/MJs until 92 or 93, I forget - long shaft
ZJs until 92 or 93, I forget - long shaft
Basically, look at the speedo takeoff. If the housing bit that gets held down with the funky clamp thing and the 1/2" bolt has a hex nut in between the sender and the housing, you need a long shaft. If it is a plastic housing, you need a short shaft.
Use a short shaft if your VSS looks like the one in this picture, used from '93/'94 or so till '01:
Use a long shaft if your VSS looks like the one in this picture, used from '91-'92/93 or so:
(this sender is in an early 90s YJ, near as I can tell. It is a special sender used in Dakotas and early 90s YJs that has a speedo cable drive output for an old mechanical speedometer, but also has an electrical takeoff for the Chrysler OBD1 ECU. XJs/MJs/ZJs from this era have a sender that looks exactly the same but doesn't have the speedo cable drive coming out the back of the sender housing. Also, the owner needs to zap-strap that VSS cable up off the rear transfer case output before it gets worn through and shorts out.)
Use a long shaft if your speedo cable setup looks like the one in this picture, used from ??-'90:
Note that the 91-92/93 (depends on who you ask, if yours looks like the second pic I posted, you have this design) VSS is actually the RENIX speedo cable and gear drive housing, just with a sensor screwed on instead of a drive cable. That's why it uses the same speedo gear setup.
edit: make sure you properly clock the VSS so that the gear engages/works and also doesn't burn up the teeth in short order.
edit 2: if you aren't doing an SYE, you are going to need to change your rear driveshaft length just so you know. 95 down vs 96 up transfer cases have different style rear outputs that require different length driveshafts.