Home All Groups Group Topic Archive Search About

Programatically figuring out if sql server 2000 or 2005

Author
18 Apr 2006 7:40 PM
Jaffa
Hi,

Is there a way to programatically tell whether I am connecting to a sql
server 2000 or sql server 2005 database. I have a connection string that
works for both versions, but when I connect to the database is there some way
to find out what version it is?

Thanks,
Matt

Author
18 Apr 2006 7:43 PM
William (Bill) Vaughn
IIRC it's SELECT @@Version
SS 2005 is version 9. something and 2000 is version 8. something. You can
also use the factory classes to enumerate this value from the metadata.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Jaffa" <Ja***@discussions.microsoft.com> wrote in message
news:B6EB2BDD-98F9-450D-841A-F46FB01EDDC7@microsoft.com...
> Hi,
>
> Is there a way to programatically tell whether I am connecting to a sql
> server 2000 or sql server 2005 database. I have a connection string that
> works for both versions, but when I connect to the database is there some
> way
> to find out what version it is?
>
> Thanks,
> Matt
Author
18 Apr 2006 7:57 PM
Sericinus hunter
Jaffa wrote:
> Hi,
>
> Is there a way to programatically tell whether I am connecting to a sql
> server 2000 or sql server 2005 database. I have a connection string that
> works for both versions, but when I connect to the database is there some way
> to find out what version it is?

    There is a system stored procedure sp_server_info which you can call
programatically. With parameter 500 it will return a row with version.
Author
18 Apr 2006 8:19 PM
Jaffa
Thanks a bunch, both methods in the previous posts work.

Show quote
"Jaffa" wrote:

> Hi,
>
> Is there a way to programatically tell whether I am connecting to a sql
> server 2000 or sql server 2005 database. I have a connection string that
> works for both versions, but when I connect to the database is there some way
> to find out what version it is?
>
> Thanks,
> Matt

AddThis Social Bookmark Button