CREATE TRIGGER must be the first statement in a batch

前端 未结 2 2237
别跟我提以往
别跟我提以往 2021-02-18 13:41

I have the below trigger:

 CREATE Trigger enroll_limit on Enrollments
 Instead of Insert
 As
 Declare @Count int
 Declare @Capacity int
 Select @Count = COUNT(*)         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-18 14:01

    If you are trying this from SQL Server Management Studio, here is another option which worked for me:

    In the left pane, right-click on the database and select "New Query".

    This connects you to the specific database. Now you can enter your create trigger statement as the first statement in the query window which opens. There is no need for a "use" command.

提交回复
热议问题