SQLServer 2000 兼容性
开发人员环境数据库服务器是SqlServer 2005(开发人员版本)
有什么方法可以确保我的SQL查询将在SqlServer 2000中运行?
该数据库设置为兼容级别“SQL Server 2000 (80)”,但某些在开发系统中运行没有问题的查询无法在测试服务器 (SqlServer) 中运行。
(问题似乎出在子查询中)
The developer environment db server is SqlServer 2005 (developer edition)
Is there any way to make sure my SQL Queries will run in SqlServer 2000?
This database is set to Compatibility level "SQL Server 2000 (80)" but some queries that run without problems in the development system can not run in the Test Server (SqlServer).
(The problems seems to be in subqueries)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
兼容性级别旨在以相反的方式工作 - 允许旧版本的 T-SQL 代码无需修改即可在新版本的 SQL Server 上运行。 这些更改通常涉及 T-SQL 语法和保留字,并且可以使用 SQL Server 2005 功能,例如兼容级别 80 的数据库索引中的 INCLUDED 列。但是,您不能使用 2005 T-SQL 功能,例如 CROSS申请。
您最好的选择是针对 SQL Server 2000 实例开发/测试所有代码。 请注意,您可以使用 2005 的 Management Studio 连接到 SQL Server 2000 实例,因此您不必使用工具。
Compatibility levels are designed to work the opposite way - to allow an older version of T-SQL code to work without modifications on a newer version of SQL Server. The changes typically involve T-SQL syntax and reserved words, and it's possible to use SQL Server 2005 features such as INCLUDED columns in indexes on a database in Compatibility Level 80. However, you can't use 2005 T-SQL features such as CROSS APPLY.
Your best option is to develop/test all your code against a SQL Server 2000 instance. Note that you can use 2005's Management Studio to connect to the SQL Server 2000 instance, so you don't have to go backwards with regards to tools.
问题已解决:
在相关子查询中,您必须(在 SQL2000 中)显式定义外部字段。
SQL2005:
SQL2000:
Problem solved:
In correlated subqueries you have to (in SQL2000) explicitly define the external field.
SQL2005:
SQL2000:
您应该始终显式定义所有字段,否则当您犯错误并编写“
If Collaboratives-table does not have column LOAN_NUMBER, the Loans-table”时,您将不会收到错误。
You should always explicitly define all fields, otherwise you will not get an error when you make a mistake and write
If Collaterals-table doesn't have column LOAN_NUMBER, the Loans-table is used instead.