I found how to get version of a SQL SERVER in different places in the internet. Here I have consolidated it in one place.
SQL Server: Different ways to know the version
1. using @@Version
2. using System Stored Procedure sp_server_info
3. using Extended Stored Procedure xp_msver
4. Using @@MicrosoftVersion
SELECT @@Microsoftversion, cast(@@Microsoftversion as binary(5))as version
Here in the version the output is 0x0009000577
Now extract first non zero character after ‘0x0’ from the binary value.
· If it is A which is represented in Hexadecimal format which denotes the number 10 so the version is 2008.
· If it is 9, the version is 2005