Hi,
It’s been a while since posts, so please bear with me on this one.
This has started recently, and I am not sure if it’s a setting or some other reason that’s causing this particular issue. And I have been able to replicate it at will.
The problem is when referencing one database, running a query and running another query on another database.
Take the following query as an example …
select *
from tblStudentProgramReg as spr
where spr.EnrolmentDate IS NULL or spr.TerminationDate IS NULL
Now if you open a database, start a new Query Editor, paste the code and run it (using your own tables of course) you would expect the query to return data based on the database connection open at the time, right? Not so if you’ve opened a another database prior to running this same query.
Steps to replicate…
- Have all your database connections closed (or start a new Toad session)
- Open ONE database
- Press CTRL-N to open an editor window
- Type (or copy/paste) some SQL code similar to the above or a simple SELECT query
- Run the query
- Double-click another database connection to say a copy of the database you opened in step 2, but make sure it has different data (old data?) so you see the difference in the next steps.
- Again CTRL-N to open an editor window
- Paste the exact same SELECT query and run
- Does the data from the 2nd query match what you expected from the SECOND database?
- If yes, good (if not read below!)
- Now re-open the database you opened in Step 2
- Open a new Editor window
- Paste the same code in again and run it
- Do you see the same data you ran in Step 5? Most likely you’re seeing the data from the SECOND database!
Even if you close the 2nd database and run the query again on the first database, you get the same data that was in the 2nd database!
This happens 100% all the time for me.
The only way around it is to reference the database directly in the SQL
select *
from **MYDB1.dbo.**tblStudentProgramReg as spr
where spr.EnrolmentDate IS NULL or spr.TerminationDate IS NULL
Even if you use the USE command at the beginning, it makes no difference. You HAVE to directly reference the database as per the above code in red.
This is definitely a bug in TOAD that I can replicate all the time. The only other way to “clear the cache” is to close and re-start TOAD again.
Anyone else experience this recently? It was not happening like a month ago, but suddenly it’s playing up like this.
Thank you
ps. We’re using TOAD SQL Server 6.1.0.1759, Professional