Ok, looks like the answer for the MSSQL service is to define the check as a new check in command.cfg, i.e check_nt_mssql or something similar, and add the service you wish to check there, however in order to escape the $ character it appears you have to use a second $, as in
and not a backslash after all. As it is written, so it shall come to pass...
command_line: This directive is used to define what is actually executed by Nagios when the command is used for service or host checks, notifications, or event handlers. Before the command line is executed, all valid macros are replaced with their respective values. See the documentation on macros for determining when you can use different macros. Note that the command line is not surrounded in quotes. Also, if you want to pass a dollar sign ($) on the command line, you have to escape it with another dollar sign.
Not sure about the IMAP one... perhaps post the check command syntax and command line test? Or maybe see if you can accomplish your goal through use of the check_imap check instead?