The general problem is that it is harder to disable someone than to kill them. Recall the case of the terrorist attack in Moscow in 2002, when terrorists from Chechnya took over a theater. In the end, the Russians pumped an anesthesia gas into the place, which killed about 130 innocent people, but allowed all 40 terrorists to be killed and allowed some 700 other people to be rescued. The problem with gas is an overdose is very easy. And people who fall asleep may involuntarily vomit and choke to death on their own emesis. So you could say the Russian solution worked--unless you were one of the 130 killed on accident. Or related to them.
Other disabling systems have the same problem. Too little of whatever you want to use and the person you intended to stun is still on his feet, ready to hurt you. Too much and you might permanently injure or kill the person you mean to stun. Ultrasonic waves or infrared heat that can disable an opponent at a certain range of energy are ineffective or overkill at others. And the systems required to set up such "stun" settings are not presently something you can just hold in your hand. And the chances are you won't be able to hold anything like that in your hand any time soon. The Star Trek "stun" setting is simply fiction. Knocking people out without killing them is a lot harder than that.
Star Wars used carbon freezing to in effect "stun" Han Solo (though Star Wars also shows a stun beam at least once), though of course if you freeze a person, the real problem comes with thawing him out. Frozen cells rupture, so a thawed person in reality is as good as dead. Star Wars offered no real solution to this problem, only hinting at the difficulty by making Han Solo temporarily blind on his release from his imprisonment. But even if you mastered the technology of freezing and rethawing, actual freezing would surely work a lot better in a controlled environment, just like anesthesia works a lot better on a surgical table than in a Moscow theater.
A pretty effective modern system revolves around pepper spray, which is usually good at causing pain and making people drop to the ground, disabled but not killed. This isn't very practical for military use, since its range is so short and it can be cancelled out by chemical protective gear (and a tiny percentage of people can ignore pepper spray anyway).
And in a science fiction context, I think you'd have no assurance that the pepper spray we use would work at all on an alien species--they might simply get angry. Or HUNGRY for that matter. :)
The modern taser gives a better example of how an effective stun system might work. The taser uses electrical pulses to in essence override the nervous system of the person its used on. This still isn't practical as a military weapon, because its range is too short. But imagine you could fire a taser rocket that would fly over to an enemy, guiding itself, then delivering the taser charge and keep it going until its owner came to turn it off. THAT might be very effective. And its stunning effect could be tailored to match the species it attacks. (Or we could imagine a self-piloting flying syringe delivering designer anesthetic.)
In fact, contemplating a future with robotic weapons incorporating computer systems that would have the ability to individually calculate dosages of anesthesia or amounts of shocking energy and monitor the person who falls afterwards, non-lethal systems suddenly become much more probable. There seems little doubt that individually fired flying projectiles, ones that could guide themselves to their target, and that could deliver a precise dose of whatever it took to knock out an opponent, such technology would seem to be an inevitable part of the future of weapons.
Note that other futuristic computerized systems are possible, not just the self-guiding projectile kind. You could have a door that automatically stuns people who attempt to break in. Or bomblets which drop from the sky, opening up into little flying or even crawling robots, seeking out people to stun. Or a nanite cloud, which in science fiction are usually portrayed as eating people alive, instead, delivering them just the right amount of anesthesia to put them to sleep.
Taking prisoners could become the standard practice in future wars, actually killing people on purpose considered barbaric and unneeded. Or at least certain science fiction races would see it that way. (Others, presumably, would not.)
So, dear friends, as you write combat scenarios in a science fiction context, don't forget the non-lethal weapons. They are certain to be the wave of the future for real military operations.