Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Irreproducable results on an SQL-statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-01 : 19:21:35
alexander writes "Dear SQLTEAM:
We have encountered a quite funny problem concerning the reproducability of SQL-queries.
For our S/W-project we wrote a rather long SQL-statement (using e.g. temporary and derived tables) yielding a single float (a sum of something) as a result in its recordset. However, it does not contain any statement that changes the database (i.e. only SELECTs).
The database itself runs on an MS SQL Server 7.0 (with Service Pack 3, I guess) under NT-Server 4.0 (SP 4). We acces it via a TCP/IP network from NT 4.0 workstations.
To check wether the SQL-statement is o.k., we tested it using the "Query Analyzer". Now, the funny thing is that we could execute this statement as often as we wanted to, and always got a different result, never the true one.
In this case, there was no other user accessing the database or even the SQL-Server. Even rebooting the machine (and thus re-starting the server) didn't change the situation.
Finally, as a last try we copied the entire database to a different machine that only runs the MSDE (using DETACH and ATTACH). Here, suddenly everything went fine. We got exactly,
what we'd expected: Reproducably the same, correct result.
So, what went wrong on in the first case? To us, it looks as if the SQL-Server was throwing dices (there's no RAND() function in the statement :-) rather than doing the DB-query.
Can anyone give us a clue to what could have gone wrong?"
   

- Advertisement -