Creating a stored procedure if it does not already exist

后端 未结 9 1164
谎友^
谎友^ 2021-02-05 01:12

I want to check if a list of stored procedures exist. I want this all to be done in 1 script, one by one. So far I have this format:

USE [myDatabase]
GO

IF NO         


        
9条回答
  •  我寻月下人不归
    2021-02-05 01:54

    Updated on Sep 2020

    You can use CREATE OR ALTER statement (was added in SQL Server 2016 SP1):

    The CREATE OR ALTER statement acts like a normal CREATE statement by creating the database object if the database object does not exist and works like a normal ALTER statement if the database object already exists.

提交回复
热议问题