Pivot Examples do not work

  • I want to explore the PIVOT statement in SQL 2005, so I looked at this article

    http://www.tsqltutorials.com/pivot.php

    and tried teh first script file:

    http://www.tsqltutorials.com/examples/CountryPivot.sql

    I tried to run this, and simply got the following error:

    Msg 102, Level 15, State 1, Line 5

    Incorrect syntax near '('.

    Anyone got any ideas why? - I tried a different tutorial and also received an error

  • I tried an example from here, and received a more useful error:

    Incorrect syntax near 'PIVOT'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.

    I then tried it on one of our development DBs and it worked fine...

    I see I can alter the compatibility level of the DB using the sp_dbcmptlevel, however, I am not sure what the implications of doing this will be?!

  • peitech (10/31/2008)


    I tried an example from here, and received a more useful error:

    Incorrect syntax near 'PIVOT'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.

    I then tried it on one of our development DBs and it worked fine...

    I see I can alter the compatibility level of the DB using the sp_dbcmptlevel, however, I am not sure what the implications of doing this will be?!

    If you want to use the features of SQL Server 2005, you need to change the

    compatibility to 90. There wont be any much impacts


    Madhivanan

    Failing to plan is Planning to fail

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply