Search code examples
sqlsql-servert-sqlsql-server-2000

comparing results from live and test servers in sql


here is my situation.

I have 2 databases which is a live and test database, the live is updated with data and the test database has data one month later than the live.

so i am simulating the work flow which has been processed in the live database and found many discrepancies.

let say i run this query

use liveDB select * from tblA

the result would produce 100 results

then

use testDB select * from tblA

the result would produce 300 results

any ideas sirs?


Solution

  • The test database is not being added to correctly or items have been removed from the live db. Check your code where the data is taken from the live to the test. Maybe you have duplicate entries. Try the following and see what you get:

    use liveDB select DISTINCT * from tblA
    use testDB select DISTINCT * from tblA
    

    Maybe if you are selecting entries from the live based on a datetime where clause, the datetime is not being interpreted correctly. SQL may be reading the datetime in US format instead of Europe of vise-versa. If you are specifying a datetime as a string try using yyyy-mm-dd format so that the month and day do not get unintentionally switched around