Sql-server – Moving to version 2016 from 2008 and Breaking Change Alert from Upgrade Advisor

sql serversql-server-2008sql-server-2016upgrade

DBMS: SQL Server

Upgrading from version 2008 to 2016.

I have this part of the code that is being flagged by the Upgrade adviser as Breaking Change.

Error: uses a constant expression which are not allowed in the ORDER BY clause in database compatibility level 90 or later

What am I missing here. To my understanding, I should not use constants here but like variables. Any help would be appreciated.

    DECLARE ForeignColumn1 CURSOR LOCAL STATIC FOR
    SELECT 
      a.COLUMN_NAME
    , ROW_NUMBER() OVER (ORDER BY a.COLUMN_NAME) AS RowNumber
    FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE a
    WHERE 1=1
    AND a.CONSTRAINT_NAME = @Constraint
    AND a.TABLE_NAME IS NOT NULL
    AND a.COLUMN_NAME NOT LIKE
    CASE 
        WHEN @SkipSite > 0 THEN 
             @CurrSite
        ELSE
             ''
        END
    ORDER BY RowNumber  

Best Answer

Going from 2008 to 2016 is jumping too far.

I suggest you to go move to 2012 first and then to 2016.

  1. First of all download Microsoft Migration Assistant and try to spot incompatibilities.
  2. Then download Microsoft Assessment and Planning Toolkit and scan for all sort of incompatibilities following a guide.
  3. Spot the incompatible queries using the Query Tuning Assistant

Now that you are on 2012 repeat the steps 1, 2 and 3 and move to 2016.