September 17, 2007 at 8:05 am
I know about @@version and SERVERPROPERTY, but I am looking for a query that will determine between SQL Server 2000 and 2005. I need to write an if/then statement and don't want to have to add all of the 9.xxx.xx versions for 2005 and keep that updated with each hotfix that comes out.
-Kyle
September 17, 2007 at 8:11 am
Kyle,
I usually use
IF CONVERT(char(1),SERVERPROPERTY('ProductVersion'))<'9' --pre SQL 2005
BEGIN...
Or something along these lines when I need to make code compatible for 2005 and older versions. Probably there are better ways but so far it worked fine for me.
Markus
[font="Verdana"]Markus Bohse[/font]
September 17, 2007 at 8:11 am
declare
@SQLV char(1)
select
@sqlv = convert(char(1),serverproperty('productversion'))
select
@sqlv
September 17, 2007 at 9:06 am
This was the answer. Thanks to all who helped. The final query looked like this...
IF CONVERT(char(1),SERVERPROPERTY('ProductVersion'))>'9' --pre SQL 2005
BEGIN
select name, is_policy_checked
from sys.sql_logins
END
Kyle,
I usually use
IF CONVERT(char(1),SERVERPROPERTY('ProductVersion'))<'9' --pre SQL 2005
BEGIN...
Or something along these lines when I need to make code compatible for 2005 and older versions. Probably there are better ways but so far it worked fine for me.
Markus
September 28, 2007 at 9:06 am
THANKS! I needed that too. I love SQLServerCentral.com.
mmmuah!
😎
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply