Fixes sql statement - to be like we have in v7 that supports all sql servers