与 SQL Server 结果不一致
我在安装 SQL Server 2008 R2 (Express) 时遇到一些问题。似乎有两个表“并行”运行。
如果我运行以下查询:
USE [database];
SELECT * FROM [dbo].[events] WHERE 1=1;
我会得到我期望的结果。但是,如果我运行此查询,我会得到一个完全错误的数据集:
SELECT * FROM [database].[dbo].[events] WHERE 1=1;
数据正在通过各种程序发送到数据库中 - 因此显然这些应用程序中的一个(或多个)正在执行错误的操作。应用程序通过 C# LINQ 连接到数据库 --> SQL DBML,DBML(我无法修改)使用 events
作为表名称(理想情况下它会使用 dbo.events
,但我无法修改/重新创建它。 )
以前有人见过这个吗?有什么方法可以使两个查询等效吗?如有必要,我可以重新创建数据库 - 那里的数据并不重要。
如果我在 SQL Management Studio 中加载数据库并右键单击选择“选择前 [1000] 行”——它会执行第二个查询(给我错误结果的那个查询...)。
编辑:
- 只有 1 个实例在运行(据我所知,现在无法访问服务器,明天会检查)
- 这两个表完全不同。查询 1 会产生大约 2,000 个项目。查询 2 会产生大约 20,000 个项目。所有物品都是独一无二的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来马丁是对的。有人搞乱了这个特定的服务器,并在不同的数据库中创建了名称完全相同的表,然后设置了一些不正确的设置,使错误的数据库成为默认数据库。
删除伪造的数据库解决了问题。
It looks like Martin is correct. Someone messed up this particular server and created tables with the exact same names in a different database, then set some incorrect settings to make the bad database the default.
Deleting the bogus database fixed the problem.