Creating procedure inside IF section

后端 未结 4 565
孤街浪徒
孤街浪徒 2021-01-04 17:54

I need some help with simple SQL code:

DECLARE @procExists int
SET @procExists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = \'d         


        
4条回答
  •  日久生厌
    2021-01-04 18:29

    From MSDN:

    The CREATE PROCEDURE statement cannot be combined with other Transact-SQL statements in a single batch.

    Therefore, what you are trying to do is not possible, unless you are fine with implementing it via a dynamic query.

提交回复
热议问题