There are three commands that can be used in SQL Server to query version information or information about the server hosting SQL Server. These commands can be run in SSMS directly, or can be used in code, for example to tailor queries for a particular database version.
The commands are xp_msver, @@Version, and sp_server_info. I have successfully used all of these commands in SQL Server 2000, SQL Server 2005, and SQL Server 2008.
Here is an example of their syntax:
EXEC xp_msver "ProductName", "ProductVersion", "Language", "Platform", "WindowsVersion", "PhysicalMemory", "ProcessorCount" ,"FileDescription" SELECT @@Version 'SQL Version' EXEC sp_server_info
The output of each of these commands is different: (more…)
