Adjusted escaping to deal with MSSQL's insano dialect for nested brackets. :P