none
uPGRADING TO SQL SERVER 2012 RRS feed

  • Question

  • Dears , 

    We recently upgraded from sql server 20008 to sql server 2012 , when running the stored procedure an error raised saying "Incorrect syntax near 'RESULT' " , after investigation we noticed that sql server does not allow any CTE named 'Result' , therefore we have changed the name from RESULT to CTERESULT and it worked fine.

    My question is : is there any walkaround that doe not contain changing all the name of CTE ? because it's not cost us a lot 

    Regards,

    Thursday, May 22, 2014 6:06 AM

All replies

  • That is kind of strange - I just tested it on SQL 2014 and using "results" as CTE name is working fine. However, I checked the MSDN Reference for reserved keywords and "RESULT" is still not reserved, but planned to be reserved. 

    Anyway, obviously you have an issue with the CTE name not allowing you to have a reserved word as identifier, hence the only option you have is either rename the CTE(as you did) or surround the CTE name with square brackets, like this: 

    ;with [KEY] (rowid) as (
    
    select 1 as rowid)
    
    select * from [KEY]
    
    This is what I can figure out. Of course, any other ideas are welcome :)

    -Ivan


    Ivan Donev MCITP SQL Server 2008 DBA, DB Developer, BI Developer

    • Proposed as answer by Olaf HelperMVP Wednesday, May 28, 2014 5:25 AM
    Tuesday, May 27, 2014 6:13 PM