As long as it is an LT style and not an LS. You can use an LS style but you will have to have a custom torque converter because bell housing clearance is different and so is input shaft.
But I just did something like this except is took a 98 model LT style 4l60e out of a 4.3 chevy blazer or s-10 (guy had it for sale and already removed for 225 bucks, damn good deal) my original tranny was in a 97 gmc sierra was a one piece with no removable bell housing. The tranny I put in was a two piece with removable bell housing but it was a non LS style. I did have to bend the tranny cooler lines a little to get them to go into the tranny, and the reluctor ring for the speed sensor on the tailshaft was different and just read the mph wrong on the dash.
Main thing in your case is to be sure to get one that is LT style and one that is 4wd. Otherwise you will need to completely disassemble both trannies and swap out tailshaft and housings to get it to be direct fit. I think I also had to slide the cross member back a little but the funny thing is thatthere were already bolt holes for it from the factory.
But as long as both of the trannies in your scenario are from a 97 and they are both 4wd then it will be a direct fit. Any tranny up to a 99 iirc, as long as it is LT style, will fit, just make sure they are both 4wd or else you will need to swap output shafts and housings