fix bug in sql and server