Is there a system stored procedure to get the version #?
+11
A:
Try
SELECT @@VERSION
or for SQL Server 2000 and above the following is easier to parse :)
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')
Joe Kuemerle
2008-09-12 16:33:27
A:
The KB article linked in Joe's post is great for determining which service packs have been installed for any version. Along those same lines, this KB article maps version numbers to specific hotfixes and cumulative updates, but it only applies to SQL05 SP2 and up.
Matt
2008-09-13 08:00:59
+1
A:
Here's a bit of script I use for testing if a server is 2005 or later
declare @isSqlServer2005 bit
select @isSqlServer2005 = case when SERVERPROPERTY('productversion') < '9.00.0000.00' then 0 else 1 end
select @isSqlServer2005
Bruce Chapman
2009-02-04 09:59:29
A:
This doesn't work for me on SQL2008, product version is 10.0.2531.0, the comparison doesn't work
Rick Hallock
2010-07-01 19:15:19
A:
try this: if (SELECT LEFT(CAST(SERVERPROPERTY('productversion') as varchar), 2)) = '10' BEGIN
freak
2010-07-05 11:05:52