Whatever might have changed by doing so had nothing at all to do with the knock sensor. It's either good or bad, and doesn't "fix" itself by disconnecting the battery. If you had a check-engine light, it wasn't the knock sensor responsible.
The knock sensor is pretty damn useless. If you have a supercharged Xterra, you need it to show "good" or your supercharger will never go out of bypass mode. On the non-supercharged ones the sensor does nothing unless you have knock, in which case you should fix the knock and not worry about the sensor.
I have the dyno numbers to prove that a bad sensor does not change the engine's behavoir one iota.
Brent