简体   繁体   中英

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. 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?

I guess there is one possibility, if in 2008 you were using 2000 compatibility mode, and your stored procedures had old-style outer joins:

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. In 2005, 2008 and 2008 R2 you could shoe-horn it in if you use 80 compatibility mode. As of SQL Server 2012, you can no longer use 80 compat mode, so the above code would fail with:

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '*='.

In 2008, you would get this error message instead:

Msg 4147, Level 15, State 1, Line 3
The query uses non-ANSI outer join operators ( "*=" 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. It is strongly recommended to rewrite the query using ANSI outer join operators (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.

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. 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. I wrote a blog about SSDT that might be helpful here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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