SQLServer 2000 兼容性

发布于 2024-07-09 08:31:59 字数 198 浏览 6 评论 0原文

开发人员环境数据库服务器是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

合约呢 2024-07-16 08:31:59

兼容性级别旨在以相反的方式工作 - 允许旧版本的 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.

沫尐诺 2024-07-16 08:31:59

问题已解决:

在相关子查询中,您必须(在 SQL2000 中)显式定义外部字段。

SQL2005:

SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE COLLATERAL_LOAN=LOAN_NUMBER)

SQL2000:

SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE COLLATERAL_LOAN=Loans.LOAN_NUMBER)

Problem solved:

In correlated subqueries you have to (in SQL2000) explicitly define the external field.

SQL2005:

SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE COLLATERAL_LOAN=LOAN_NUMBER)

SQL2000:

SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE COLLATERAL_LOAN=Loans.LOAN_NUMBER)
雨轻弹 2024-07-16 08:31:59

您应该始终显式定义所有字段,否则当您犯错误并编写“

SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE LOAN_NUMBER=Loans.LOAN_NUMBER)

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

SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE LOAN_NUMBER=Loans.LOAN_NUMBER)

If Collaterals-table doesn't have column LOAN_NUMBER, the Loans-table is used instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文