If possible, try to use standard SQL as much as possible. In other words, don't use SQL dialect specific to a SQL server.
Another way is to have a SQL statements defined similar to the way a translation would. For example, you have a list of SQL statements for MSSQL in one file and for MySQL in different file. Depending on configuration of which database is used, one of the 2 files are loaded.