All decks greater than 30" above grade must have a guardrail. If you choose to install a guardrail on a deck lower than 30" you must still meet code requirements. Decks attached to single family detached homes are regulated under the rules of the International Residential Code (IRC). The IRC requires guardrails to be at lest 36" in height measured from the deck surface to the top of the rail. Commercial decks attached to multifamily buildings such as apartment buildings or businesses are regulated under the Internation Building Code (IBC). The IBC requires 42" high guardrails. In either case you are allowed to build taller guardrails as long as they conform to all other requirements stated in the code.