I often have scripts that run across multiple versions of SQL … more and more 2008’s and less and less 2000’s. In doing so, i need to take different actions based on that version. Here’s the simple technique that i have developed … it currently depends on Microsoft continueing to use periods in their version naming scheme… i don’t think that that will change soon!
select ltrim(substring(@@version,CHARINDEX(‘.’,@@version)-2,2))
Steve