I have written a query using PIVOT function.The db is on client side. When i am running the query it throws an 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 SET COMPATIBILITY_LEVEL option of ALTER DATABASE.
After this I ran these two queries,
SELECT @@version;
SELECT compatibility_level FROM sys.databases WHERE name = 'db_name';
The output is
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)
Jun 17 2011 00:54:03
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
and
80
I am not a db expert, But what I guess is they are using SQL server 2008 with compatibility mode of SQL server 2000 i.e 80 .Let me know if I am wrong. I do not think the Client will agree to change the compatibility level. So Is there any way to run a PIVOT query?