One of my colleague was asking a follow up question on my earlier post DROP IF EXISTS A handy feature in SQL Server 2016
Do we have something similar for Creating objects?
The good news is that we have “CREATE or ALTER” in SQL Server 2016 to address our long waiting requirement. However, this will not be available in RTM, but only from SP1 and above.
Applies to : SQL Server 2016 SP1 or later versions
Here is a small script to verify the same.
SQL Script:
--Creating the procedure first time CREATE OR ALTER PROCEDURE SP_TEST AS BEGIN SELECT 2 END GO EXEC SP_TEST GO --Altering the procedure CREATE OR ALTER PROCEDURE SP_TEST AS BEGIN SELECT 200 END GO EXEC SP_TEST
Note: This can also be used for Function objects to create or alter operations.