SQL Server Express 是否兼容 ANSI?
可以在 SQL Server Express 2005 或 2008 中运行 ANSI SQL 语句吗?
Can you run ANSI SQL statements in SQL Server Express 2005 or 2008?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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.
如果您的产品仅使用 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.
它仅部分符合 ANSI 标准。最大的区别是字符串连接运算符,它应该是
||
,但在SQL Server 中是+
。此外,根据当前数据库的排序规则,它可能不符合标准要求的区分大小写的规则。
缺少的其他(我认为必需的)ANSI 功能:
DATE '2012-08-28'
、TIMESTAMP '2012-08-28 17:33:05 '
)VALUES
(在INSERT
子句之外)(col1, col2) = (1,2 )
ORDER BY
的NULLS 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:
DATE '2012-08-28'
,TIMESTAMP '2012-08-28 17:33:05'
)VALUES
(outside of theINSERT
clause)(col1, col2) = (1,2)
NULLS FIRST/LAST
option forORDER 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.