SQL Server Express 是否兼容 ANSI?

发布于 2024-08-10 23:25:53 字数 59 浏览 6 评论 0原文

可以在 SQL Server Express 2005 或 2008 中运行 ANSI SQL 语句吗?

Can you run ANSI SQL statements in SQL Server Express 2005 or 2008?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

有木有妳兜一样 2024-08-17 23:25:53

Sql Server 理解 Ansi Sql。然而,对于标准总是有不同的解释。这是我发现的一篇文章,列出了一些差异:Think ANSI Standard SQL Is Complete Portable Between数据库?再想一想。

Sql Server understands Ansi Sql. However there are always different interpretations of the standards. Here is an article that I found that lists some of the differences: Think ANSI Standard SQL Is Fully Portable Between Databases? Think Again.

GRAY°灰色天空 2024-08-17 23:25:53

如果您的产品仅使用 SQL Server 后端,请忘记 ANSII sql,T-SQL 有更高效且有效的方法来查询 SQL Server 数据库。如果您必须拥有多个后端,则 ANSII 是可以的,但如果您没有,那么将自己限制在可用的最低效代码上是愚蠢的。对于任何数据库后端都是如此,该数据库的专有语言被设计为比其他任何语言都运行得更好。

但回答你的问题时,是的,有些 ANSII 标准有效,有些则无效。对于任何基本的查询,你可能没问题,复杂的东西往往会真正指出差异。所以基本上你无法摆脱所有测试。无论如何你都应该这样做。

If you are only using SQL Server backends for your product, forget about ANSII sql, T-SQL has much more efficient and effective ways of querying a SQL Server database. ANSII is ok if you have to have a multiple backends, but if you don't it is stupid to limit yourself to the least effective code available. This is true of any database backend, the proprietary language for that database is designed to run better than anything else.

But in answer to your question, yes some of the ANSII standard works and some of it does not. For any basic queries you may be ok, it is the complex stuff which tends to really point out the differences. So basically you can't get out of testing it all. Which you should be doing anyway.

浅沫记忆 2024-08-17 23:25:53

它仅部分符合 ANSI 标准。最大的区别是字符串连接运算符,它应该是||,但在SQL Server 中是+

此外,根据当前数据库的排序规则,它可能不符合标准要求的区分大小写的规则。

缺少的其他(我认为必需的)ANSI 功能:

  • 没有 ANSI 日期/时间文字(DATE '2012-08-28'TIMESTAMP '2012-08-28 17:33:05 ')
  • 无间隔数据类型
  • 行构造函数 VALUES(在 INSERT 子句之外)
  • 无元组比较 (col1, col2) = (1,2 )
  • ORDER BYNULLS FIRST/LAST 选项

不过,大多数缺失的功能在 T-SQL 中都有一些非标准的等效功能。

SQL 标准是一件好事,如果我可以在两种 SQL 结构之间进行选择,我会选择标准结构而不是非标准结构。

但是编写独立于 DBMS 的应用程序根本行不通(很好)——至少对于重要的应用程序来说是这样。

如果它真正独立于 DBMS,则仅意味着它在所有 DBMS 上都同样慢。

您为所有 SQL Server 功能支付了很多现金(或者为 SQL Server Express 支付了不多的钱),所以去使用它们吧。

It is only partially ANSI compliant. The biggest difference is the string concatenation operator which should be || but is + in SQL Server.

Additionally depending on the collation of the current database it might not comply with the case-sensitivity rules required by the standard.

Other (I think required) ANSI features that are missing:

  • no ANSI date/time literals (DATE '2012-08-28', TIMESTAMP '2012-08-28 17:33:05')
  • no interval datatype
  • The row constructor VALUES (outside of the INSERT clause)
  • No tuple comparison (col1, col2) = (1,2)
  • NULLS FIRST/LAST option for ORDER BY

Most of the missing features have some non-standard equivalent in T-SQL though.

The SQL standard is a nice thing and if I have a choice between two SQL constructs I choose the standard one over the non-standard one.

But writing DBMS-independent applications is simply not going to work (well) - at least not for non-trivial applications.

If it is truly DBMS independent it merely means it will be equally slow on all DBMS.

You paid a lot of cash for all SQL Server features (or not so much for SQL Server Express) so go use them.

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