Just run the code in the database you want and add the following in your T-SQL scripts:
select * from dbo.udf_SQLVersionInfo()
This returns several columns. If you just want to check on a version number, you could run:
if (select ProductValue from dbo.udf_SQLVersionInfo()) > 10.0 ...
update: removed licensetype, support for MSSQL 2000, added HadrStatus, Isclustered and FulltextInstalled