SQL SERVER compatibility fixes