Putting someone under and keeping them there safely isn’t particularly difficult, but it does require someone to be actively monitoring the patient/subject/victim, and adjusting the dosage to make sure nothing goes wrong. If something does, you’ll need them, or end up with a corpse.
Properly overseen, it’s safe enough that we can use this on a daily basis in medical environments. It is a fundamental step in any major surgery after all. But, that’s with complete access to the patient’s medical history, and someone on hand who’s only job is making sure they don’t die on the table, from the sedatives.
Seriously, anesthesiologists are a very important part of modern surgery. You, literally, can’t do it without them.
But, that’s not combat. When you’re talking about something like a hostage situation, it’s not a safe option.
The biggest example is the Moscow Theater Hostage Crisis. In 2002 Chechens took 850 hostages and issued demands. The Russian solution was to try sedating everyone with a chemical agent. Which killed 130 of the hostages, and hospitalized at least 650 more.
I should probably stress, with chemical agents, it’s not that you can’t knock someone out with some kind of gas grenades, it’s just that it will kill some people. It’s also not instantaneous. Even if you’re trying to sedate someone like this, they will have time to respond. If they’ve got a gas mask, and the presence of mind to put it on, your entire plan failed. If they don’t, that’s still time to detonate a suicide vest, or start shooting.
There is also a serious risk of long term side effects from exposure that last long after. This will depend on the specific chemicals used.
It’s not safe by any stretch of the imagination. It can be the best of many bad options, but short of technology that does not exist, or magic, there is no safe way to knock someone out. We do not have the means to achieve that.