简体   繁体   English

从SQL Server 2008迁移到SQL Server 2012 Express

[英]Moving from SQL Server 2008 to SQL Server 2012 Express

I am moving an app from SQL Server 2008 to SQL Server 2012 Express, and all is well but several stored procedures are saying I have a syntax error. 我正在将一个应用程序从SQL Server 2008迁移到SQL Server 2012 Express,一切都很好,但是几个存储过程说我有语法错误。 I have looked online and have not found an answer - are there types of syntax that are supported in SQL Server 2008 (Standard) but not in SQL Server 2012 Express? 我在网上查看并没有找到答案-SQL Server 2008(标准版)中是否支持某些语法类型,但SQL Server 2012 Express中不支持?

I guess there is one possibility, if in 2008 you were using 2000 compatibility mode, and your stored procedures had old-style outer joins: 我猜有一种可能,如果在2008年您使用的是2000兼容模式,并且您的存储过程具有旧式的外部联接:

SELECT o.name, c.name
FROM sys.objects AS o, sys.columns AS c
WHERE o.[object_id] *= c.[object_id];

This syntax works in SQL Server 2000, but has been deprecated since then. 此语法在SQL Server 2000中有效,但此后不推荐使用。 In 2005, 2008 and 2008 R2 you could shoe-horn it in if you use 80 compatibility mode. 在2005、2008和2008 R2中,如果使用80兼容模式,您可以试一下。 As of SQL Server 2012, you can no longer use 80 compat mode, so the above code would fail with: 从SQL Server 2012开始,您将无法再使用80兼容模式,因此上述代码将因以下原因而失败:

Msg 102, Level 15, State 1, Line 3 Msg 102,第15级,状态1,第3行
Incorrect syntax near '*='. '* ='附近的语法不正确。

In 2008, you would get this error message instead: 在2008年,您将收到以下错误消息:

Msg 4147, Level 15, State 1, Line 3 Msg 4147,第15级,状态1,第3行
The query uses non-ANSI outer join operators ( "*=" or "=*" ). 该查询使用非ANSI外部联接运算符( "*=" or "=*" )。 To run this query without modification, please set the compatibility level for current database to 80, using the SET COMPATIBILITY_LEVEL option of ALTER DATABASE. 要不加修改地运行此查询,请使用ALTER DATABASE的SET COMPATIBILITY_LEVEL选项将当前数据库的兼容性级别设置为80。 It is strongly recommended to rewrite the query using ANSI outer join operators (LEFT OUTER JOIN, RIGHT OUTER JOIN). 强烈建议使用ANSI外部联接运算符(LEFT OUTER JOIN,RIGHT OUTER JOIN)重写查询。 In the future versions of SQL Server, non-ANSI join operators will not be supported even in backward-compatibility modes. 在SQL Server的将来版本中,即使在向后兼容模式下也将不支持非ANSI连接运算符。

But if you alter the database as suggested in the error message, it would work: 但是,如果您按照错误消息中的建议更改数据库,则它将起作用:

ALTER DATABASE foo SET COMPATIBILITY_LEVEL = 80;

This seems like a stretch. 这似乎是一个拉伸。 But without some real information it's about the only guess I have. 但是没有一些真实的信息,这是我唯一的猜测。

Here's a list of deprecated features in SQL Server 2012-- take a look at the T-SQL section(s) in particular. 这是SQL Server 2012中不推荐使用的功能的列表 -特别看看T-SQL部分。 You could also use SSDT (SQL Server Data Tools), create an offline copy of your DB and then set the version targeting to SQL Server 2012 - the output would show show many of the syntax incompatibilities between versions. 您还可以使用SSDT(SQL Server数据工具),创建数据库的脱机副本,然后将目标版本设置为SQL Server 2012-输出将显示出版本之间的许多语法不兼容。 I wrote a blog about SSDT that might be helpful here . 我写了一篇博客有关SSDT可能会有所帮助这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM