Version Specific Snippets Script Blocks
I would like to be able to specify different script blocks inside a snippet that would work differently based upon the sql server version of the server I am connected to.
Or.... optionally have a version indicator on the snippet to perform the same thing. Then if two snippets share the same name it would apply the correct one based upon version.
EX:
:if $version_major$ >= 13
CREATE OR ALTER PROCEDURE [$dbo$].[$proc_name$] (@param1 INT) AS BEGIN
$CURSOR$SELECT @param1
END
GO
:else
IF OBJECT_ID('[$dbo$].[$proc_name$]', 'P') IS NULL BEGIN
EXEC('CREATE PROCEDURE [$dbo$].[$proc_name$] AS BEGIN SELECT 1; END;')
END
GO
ALTER PROCEDURE [$dbo$].[$proc_name$] (@param1 INT) AS BEGIN
$CURSOR$SELECT @param1
END
GO
:endif
1
vote
Tim Cartwright
shared this idea