Fixed bug for SQL Server