I'm having some trouble with a SQL Server 2008 R2 (Express) installation. It seems like there are two tables operating in "parallel".
If I run the following query:
USE [database];
SELECT * FROM [dbo].[events] WHERE 1=1;
I get the results I expect. However, if I run this query, I get a dataset that is completely wrong:
SELECT * FROM [database].[dbo].[events] WHERE 1=1;
Data is being sent into the database by a variety of programs -- so obviously one (or more) of these apps is doing something wrong. The apps connect to database via a C# LINQ --> SQL DBML, the DBML (which I cannot modify) uses events as the table name (ideally it would use dbo.events, but I can't modify/recreate it.)
Has anyone seen this before? Is there some way to make the two queries equivalent? I can recreate the database if necessary - the data in there is not critical.
If I load up the database in SQL Management Studio and right click to select "Select top [1000] rows" -- it executes the second query (the one that gives me the wrong results...).
Edit:
- There is only 1 instance in play (as far as I know anyway -- don't have access to the server right now, will check tomorrow)
- The two tables are totally different. Query 1 results in 2,000 or so items. Query 2 results in 20,000 or so items. All items are unique.
ORDER BYon the selects. Although the probability is that SQL Server is querying the data in exactly the same way, it's a horrendously quick sanity check. Once that's checked out then it's worth looking at other possibilities (e.g., you aren't running multiple instances of SQL on one server and connecting to different ones). Basically what you're seeing just sounds wrong from a fairly fundamental level, so it's worth checking all the basics first.