CREATE OR ALTER Supported in Service Pack 1 of SQL Server 2016

New CREATE OR ALTER support makes it easier to modify and deploy objects like Stored Procedures, Triggers, User–Defined Functions, and Views. This feature is introduced in SQL Server 2016 SP1.

 

OLD syntax Example

IF EXISTS (SELECT NAME FROM SYSOBJECTS WHERE NAME = ‘spMyProcedure’ AND TYPE = ‘P’)
BEGIN
DROP PROCEDURE spMyProcedure
END
GO
CREATE PROCEDURE spMyProcedure (@Name VARCHAR(100))
AS

DECLARE @MyVar VARCHAR(10)
SET @MyVar = ‘Geek!’
BEGIN
SELECT @Name +’ Is a ‘ + @MyVar
END
GO

New syntax Example

 

CREATE OR ALTER PROCEDURE spMyProcedure (@Name VARCHAR(100))
AS

DECLARE @MyVar VARCHAR(10)
SET @MyVar = 'Geek!!!!'
BEGIN
 SELECT @Name +' Is a ' + @MyVar
END
GO

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s