SERVERPROPERTY('ProductVersion') value in Windows Server 2008 + SQL Server 2012 - sql-server-2012

Having an environment Windows Server 2008 + SQL Server 2012.
SELECT SERVERPROPERTY('ProductVersion')
Will the below query return 11.X.XXXX.XX or 10.XX.XXXX.X
Please share whether SERVERPROPERTY function checks the SQL Server version or Windows Server version.
Please help me out.

From the official documentation for SERVERPROPERTY:
ProductVersion Version of the instance of SQL Server, in the form of 'major.minor.build.revision'.
So SELECT SERVERPROPERTY('ProductVersion') will give you the database engine version. To get information about the OS, use sys.dm_os_windows_info:
select * from sys.dm_os_windows_info

Related

SQL server shows different versions when seen from about screen and from query

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.

Error: Can't attach DB to SQL Server 2012

I have SQL Server 2012 and I'm trying to attach a db which was previously used with SQL Server 2012, surprisingly I'm getting the following error:
The database 'DatabaseName' cannot be opened because it is version
706. This server supports version 622 and earlier. A downgrade path is not supported.
I don't really understand how this could happen since like I said it was used with same 2012 version. What am I doing wrong? How can I make it work? Please explain in detail how this can be resolved.
Thank you!!
The error sounds like the server you are trying to attach the database to is not SQL Server 2012. This may be the version of Management Studio / Management Studio Express you're using, but I suspect SELECT ##VERSION; will tell you something different. It may just be a connection string mixup if you have multiple instances of SQL Server installed, otherwise you should download and install SQL Server 2012 Express from here.
#source
It sounds like you had the following configuration and source databases:
SQL Server 2008 SP3 (ver 10.0...) - database engine
SQL Server Management Studio 2012 (ver 11.0...) - management tools
a database that was created with SQL Server 2012 (version 706)
As mentioned you could install SSMS for SQL Server 2008 (after you uninstall SSMS for SQL Server 2012). Then you would have to script your database for that version and re-run the script via 'Tasks>Script...', remembering to set the target server version as shown below.
After scripting you can then use the import/export wizard to export and then inport the data into the new (downgraded database), assuming the database had no 2012-only datatypes (such as sequences).
Another consideration is database compatibility level as shown below. You can have a SQL Server 2012 instance which hosts databases with various compatibility levels.
Using SELECT ##VERSION works very well for me. Your Database Engine is connected to a 2008 DB which certainly doesn't allow you to attach. Once I change my Database Engine to connect to 2012 DB, it works for me.
Check your Database Engine connection. You can be working on 2012 Management Studio yet connecting to 2008 DB. This is what happened to me and I have solved it use SELECT ##VERSION.

problem in connecting studio management to sql server

I had installed SQL Server 2008, but faced some complications with that. I then installed SQL Server 2005, and now installed SQL Server Management Studio for SQL Server 2005 successfully.
I am not able to connnect to the server name it suggests.
TITLE: Connect to Server
Cannot connect to POONAM-C586A95C\SQLEXPRESS.
ADDITIONAL INFORMATION:
This version of Microsoft SQL Server Management Studio Express can only be used to connect to SQL Server 2000 and SQL Server 2005 servers. (Microsoft.SqlServer.Express.ConnectionDlg)
It doesn't show any other option of SQL Server name, though I changed the name as I remembered but for no good.
How can this be solved?
It sounds as if you're trying to connect to the 2008 instance with the 2005 SSMS. It's not clear whether you un-installed the 2008 instance.
Suggest installing the SQL Server 2008 SSMS.
Confirm/modify as needed that you're running the SQL Server instance that you require. This will show you which instances are available.
I would also check to make sure that you're connecting to the correct port. I'm come across a similar error before and the solution was to specify the port to connect to, i.e.
compname\instancename,portnum

sql server 2008 and 2005 on same machine?

I already have sql server 2008 installed and now need to install 2005 express as well. When I try this, the installation fails with: "An installation package for the product Microsoft SQL Server VSS Writer cannot be found" - any ideas anyone?
Yes, you can definitely have both SQL Server 2005 (any edition) and SQL Server 2008 (any edition) on the same machine. But of course - you cannot have both be the default instance (which you access without specific instance name). Typically that's not a problem since the Express editions default to the .\SQLEXPRESS instance name. Just something to remember when installing.
HOWEVER: you need to make sure to first install your SQL Server 2005 and then the 2008 edition. It won't work the other way around, unfortunately.
So in your case: you'll need to first uninstall SQL Server 2008m, then install SQL Server 2005 Express and SQL Server 2008 on top of that again.

Programmatically detect SQL Server Edition

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?