CREATE TRIGGER必须是批处理中的第一个语句 [英] CREATE TRIGGER must be the first statement in a batch
本文介绍了CREATE TRIGGER必须是批处理中的第一个语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下触发器:
CREATE Trigger enroll_limit on Enrollments
Instead of Insert
As
Declare @Count int
Declare @Capacity int
Select @Count = COUNT(*) From Enrollments
Select @Capacity = Capacity From CourseSections
If @Count < @Capacity
Begin
Insert Into Enrollments Select * From Inserted
End
GO
我收到一条错误消息:
CREATE TRIGGER必须是查询中的第一条语句
'CREATE TRIGGER' must be the first statement in a query batch.
推荐答案
错误消息'CREATE TRIGGER'必须是查询批次。通常发生在前一组(批)语句没有终止的 GO
The error message "'CREATE TRIGGER' must be the first statement in a query batch." usually occurs when a preceding group (batch) of statements does not have a terminating GO
在前一个批处理语句的末尾添加 GO
。
So, I would suggest adding add a GO
to the end of the preceding batch's statements.
这篇关于CREATE TRIGGER必须是批处理中的第一个语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文