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?
Related
When trying to attach a database file to:
Microsoft SQL Server 2008 (SP2) - 10.0.4000.0 (X64) Sep 16 2010 19:43:16 <X64> (Build 7600: )
I get this error message:
The database cannot be opened because
it is version 661. This server
supports version 662 and earlier. A
downgrade path is not supported.
Any idea why? and how to solve it?
SQL Server 2008 databases are version 655. SQL Server 2008 R2 databases are 661. You are trying to attach an 2008 R2 database (v. 661) to an 2008 instance and this is not supported. Once the database has been upgraded to an 2008 R2 version, it cannot be downgraded. You'll have to either upgrade your 2008 SP2 instance to R2, or you have to copy out the data in that database into an 2008 database (eg using the data migration wizard, or something equivalent).
The message is misleading, to say the least, it says 662 because SQL Server 2008 SP2 does support 662 as a database version, this is when 15000 partitions are enabled in the database, see Support for 15000 Partitions.docx. Enabling the support bumps the DB version to 662, disabling it moves it back to 655. But SQL Server 2008 SP2 does not support 661 (the R2 version).
To clarify, a database created under SQL Server 2008 R2 was being opened in an instance of SQL Server 2008 (the version prior to R2). The solution for me was to simply perform an upgrade installation of SQL Server 2008 R2. I can only speak for the Express edition, but it worked.
Oddly, though, the Web Platform Installer indicated that I had Express R2 installed. The better way to tell is to ask the database server itself:
SELECT ##VERSION
I had to see version of my sql server management studio, I went to Help --> About, it showed me following screen:
link to image: About Screen of my SQL Server Management Studio
It clearly shows that SQL Server is R2 with version 10.50.1600.1.
But when I run query
Select ##version, It returns me this:
Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86) Mar 29 2009 10:27:29 Copyright (c) 1988-2008 Microsoft Corporation Express Edition on Windows NT 5.1 (Build 2600: Service Pack 3)
Which shows it is not R2, also version is changes i.e 10.0.2531.0
I am not getting why is this? Can someone explain why both enquiries return different versions. Although I installed R2 in it.
And if it is not R2 then how to upgrade it to R2. Please help
You can see version of SQL Server on local computer by using Help\About. but when run select ##Version, you see version of SQL Server database engine that login on it. In other word you run SSMS from local computer and Help\About show version of SSMS. and then login to sql server database engine of your server, Select ##Version show version of sql server on the server.
I am getting the following error while trying to configure FileStream in SQL server 2012.
There was an unknown error applying the filestream settings. check the parameters are valid. (0x80041008)
I am configuring it using SQL server configuration manager.
Where as I am able to setup it for SQL server 2008 R2.
I had this same problem just yesterday.
In my case it was because I had a 64-bit Windows and a 32-Bit SQL Server.
You do not see the exact error, but if you try to do it with T-SQL, then the proper error comes up in SQL, telling you something about "WOW64" not supporting filestream.
I just uninstalled and installed the right bit version of SQL, and all worked 100% again.
In my case the problem I was running the SQL Server 2014 configuration manager. While this usually shouldn't cause problems, in my case it did. Configuring FILESTREAM using the SQL Server 2012 configuration manager worked.
If it still doesn't work, make sure you're up-to-date. SQL Server 2012 has received quite a lot of patches (SP2, SP3, and some updates).
TL;DR
I simply installed Service pack 2 (SP2) patch of SQL Server 2008 R2 and everything started working for me.
Read on if you want to know more. Configuration wise my box was all correct and the file stream feature should have been working on my default instance of SQL Server 2008 R2. Here are my box details:
Operating System: Windows 7 Ultitmate SP1 (64 Bit)
SQL Server Version: SQL Server 2008 R2 SP1
On SQL Server if I run this query select ##version it was returning following details:
Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
Whenever I opened SQL Server 2008 Configuration manager I will face this issue. Luckily I also had SQL Server 2014 installed on my machine. So I tried enabling File Stream feature from configuration manager GUI of SQL Server 2014 but it started giving error mentioned in current post.
I simply installed Service pack 2 (SP2) patch of SQL Server 2008 R2 and everything started working for me. SQL Server Configuration manager for 2008 R2 also works fine and I'm able to enable File Stream feature also without any trouble. SQL Server 2008 R2 SP2 can be downloaded from here.
I installed the SQL Server 2012- Developer edition. When I apply SELECT ##version, I get:
Microsoft SQL Server 2005 - 9.00.5000.00 (Intel X86)
Dec 10 2010 10:56:29
Copyright (c) 1988-2005 Microsoft Corporation
Express Edition on Windows NT 6.1 (Build 7601: Service Pack 1)
But when I go to help, then about, It shows that it's SQL Server 2012.
I'm trying to use the EOMONTH function and I'm getting an error that the EOMONTH is unrecognizable built in function. Can anybody please help me understand what's going on? Thanks!I'm fairly new to T-SQL.
You might be connecting to an instance of SQL Server 2005 from SSMS 2012.
Make sure you select correct server/instance while connecting to Database Engine.
I'm using C# with SMO and attempting to detect what edition of SQL Server (e.g., enterprise, standard) I'm connecting to. I know how to get the version information, but that only tells me what version of SQL Server (e.g., SQL Server 2008 vs SQL Server 2005).
Does anyone know how to get the actual product edition (e.g., enterprise, standard)?
I need this information because some SQL Server features are only enterprise. Thus, I could just try to call them and catch the exception, but I'd much prefer an upfront detection.
Thanks!
SELECT SERVERPROPERTY('productversion'),
SERVERPROPERTY ('productlevel'),
SERVERPROPERTY ('edition')
on my system returns
9.00.1399.06, RTM, Express Edition
It seems this technique only works on SQL Server 2000 or later, if any of your databases are 7.0 or less, you'll have to use ##Version and manipulate the results as others have posted
It looks like you might be able to do it via SMO and the Server object. There are properties like Information.Edition which looks like it should do what you want.
I've always used ##Version (eg. SELECT ##Version and manipluted the result in code), but this article looks pretty handy;
http://support.microsoft.com/kb/321185
The only issue with using SERVERPROPERTY, as per the link... is that this won't work with older version of SQL Server.
select ##version
Returns version and which edition. Here:
Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86)
Nov 24 2008 13:01:59
Copyright (c) 1988-2005 Microsoft Corporation
Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
Check the registry. This question had a good method you could adapt from the PowerShell script:
How do I check for the SQL Server Version using Powershell?