gpt4 book ai didi

sql-server - CREATE TRIGGER 必须是批处理中的第一个语句

转载 作者:行者123 更新时间:2023-12-02 02:44:47 24 4
gpt4 key购买 nike

我有以下触发器:

 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' must be the first statement in a query batch.

最佳答案

错误消息“'CREATE TRIGGER'必须是查询批中的第一个语句。”通常在前面的一组(批处理)语句没有终止 GO

时发生

因此,我建议在前一个批处理语句的末尾添加 GO

关于sql-server - CREATE TRIGGER 必须是批处理中的第一个语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13370505/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com