Use the following query to determine the version and build information for Microsoft SQL Server:
select @@microsoftversion / 0x01000000 as version, cast(cast(@@microsoftversion as binary(2)) as int) as build;
The query returns the version number will be 7 for SQL Server 7.0, 8 for SQL Server 2000, 9 for SQL Server 2005 and 10 for SQL Server 2008. To determine the service pack level and edition information, please refer to this Microsoft Knowledge Base article.