Blog Post

SQL Server Blog
1 MIN READ

CREATE OR ALTER - another great language enhancement in SQL Server 2016 SP1

JovanPop's avatar
JovanPop
Icon for Microsoft rankMicrosoft
Mar 23, 2019
First published on MSDN on Nov 17, 2016
We are happy to announce that SQL Server 2016 SP1 and SQL Server v.Next have new T-SQL language statement - CREATE [OR ALTER]. This statement combines CREATE and ALTER statements and creates object if it does not exist, or alter it if it is already there. CREATE OR ALTER can be applied on the following object:

This is one of the most voted language feature requests on SQL Server connect site with more than 500 votes. A code that uses CREATE OR ALTER is shown in the following example:
create or alter procedure procTest
as
begin
print (1)
end;
go
create or alter function fnTest()
returns int
as
begin
return(1)
end;
go
create or alter view vwTest
as
select 1 as col;
go
create or alter trigger trTest
on Product
after insert, update
as
RAISERROR ('We love CREATE OR ALTER!', 1, 10);
We hope that this statement would help you to to write easier T-SQL code.

EDIT (11/17/2016): This and other SQL Server 2016 SP1 topics are also available in the SQL Server Tiger blog.
Updated Mar 23, 2019
Version 2.0
No CommentsBe the first to comment