some fixes using MS SQL