为什么 SQL Server 2000 中的这个简单 SQL 查询在 SQL Server 2008 中会有不同的结果?
使用 MS SQL 2000 可以进行如下查询:
SELECT (Code + ' = ' + EdiNumber + ',') AS MyResult FROM tblCountry
它将为您提供一个结果列表,例如:
MyResult
========
ZW = 263,
ZA = 27,
...
但是,在 MS SQL 2008 中该查询返回:
-1 records affected
有谁知道 a) 为什么? b) 如何从 SQL 2008 获取 SQL 2000 结果?
更新
我只是使用标准 ASP.NET 连接字符串来连接到数据库,并使用控制台发布查询:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True; Database=MyDB
Using MS SQL 2000 it was possible to have a query such as:
SELECT (Code + ' = ' + EdiNumber + ',') AS MyResult FROM tblCountry
Which would give you a list of results like:
MyResult
========
ZW = 263,
ZA = 27,
...
However, in MS SQL 2008 that query returns:
-1 records affected
Does anyone know a) Why? and b) How to get the SQL 2000 result from SQL 2008?
UPDATE
Im just using a standard ASP.NET connection string to connect to the database using a console to post the query:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True; Database=MyDB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

问题已解决
-1 条记录受影响
显然是非特权结果,因为实际发生的只是在尝试连接字符串时查询中出现错误
code> (Code) 和int
(EdiNumber)正确的查询应该是:
一旦我得到正确的结果,查询就可以从原始控制台正常工作。
PROBLEM SOLVED
-1 records affected
was clearly the non-privileged result because all that was actually happening was an error in the query whilst trying to concatenate astring
(Code) and anint
(EdiNumber)The correct query should have been:
Once I got that correct, the query worked fine from the original console.