The rule is that in a closed syllable (that ends with a consonant) that is unaccented, the qamets will be qamets chatuph. For example, in the noun חָכְמָה, the two syllables are חָכְ and מָה. The second is accented, and so the first qamets is chatuph.
The example in Zechariah 9:2 that @DoubleAA brings up above is not the noun, but a conjugation of the verb. In this case, the syllable structure is first חָ, second כְ (with a sheva na), and third מָה. Thus, the above rule does not apply. In addition, to obviate confusion, there is a meteg (a small line) next to the qamets on the ח. This is a secondary stress mark, and says that the qamets is pronounced fully, and is not chatuf. There are exceptions to the effect of the meteg, and they're usually on words with a makef (eg. Deut 15:10 בכָל־מעשך).
Every rule has a few exceptions, but the most common exception is the word בָּתִּים, where the accent is on the second syllable, and the dagesh in the ת indicates that the syllable structure is בָּת and תִים. To avoid this seeming contradiction, some tikkuns will print the dagesh as qal (weak) instead of the chazak that it should be. The other exceptions to the rule are with makefs, like Num 34:3 (יָם־המלח).
Support: second paragraph of Gesenius' grammar says that a sheva after an unaccented long vowel is na, hence in a closed syllable, the vowel can't be long.