sql - Incorrect syntax near 'PIVOT' -


i'm running sql server 2008 r2. i'm trying build table takes data table structured this:

company | ded_id | descr  10          1      medins 10          2      life 10          3      pensn ... 10         50      domrel 

and need build temp table out format this:

company | desc1 | desc2 | desc3 ... | desc50 10        medins  life    pensn       domrel 

so built following query:

    select *     (     select company,'desc'+cast(ded_id varchar(2)) dedid,descr     deduction          ) deds     pivot (max(descr)for dedid in([desc1],[desc2],[desc3])) descs 

so running gives following error:

msg 325, level 15, state 1, line 6 incorrect syntax near 'pivot'. may need set compatibility level of current database higher value enable feature. see set compatibility_level option of alter database.

i double checked compatibility level on database , set 100 can't issue. can think of other setting might causing behavior?

the possible reason type of issue imported database other source might running older version of sql server. anyway, have way out of it. follow steps below:

  1. right click on database (e.g. northwind).
  2. click 'properties'.
  3. click 'options', left pane, under 'select page' section.
  4. select appropriate database version per installation drop-down of 'compatibility level' @ right.
  5. save changes , try now.

below screenshot of properties window reference.

enter image description here


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -