sql server - T-SQL: Execute command in case block -


is there possible way execute in t-sql?

case @@version  when 'sql server 2005' command_a else command_b end 

this case block should pick command_a if server version 2005. if not command_b should executed.

actually case "subcommand" of select achieve want this:

declare @s varchar(255) select @s = case @@version  when 'sql server 2005' 'command 1' else 'command 2' end exec (@s) 

Comments