SQL Server:无效游标状态(0)状态为什么?
我有一个表,上面写有更新触发器,它在 go 语句之前有 print 语句。
ALTER TRIGGER user_type_check ON user_table --code PRINT 'Modification of user is done.' GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
现在有了这个结构,每当我对表执行更新操作时,它都会失败。
但是,当我将 PRINT 语句移到触发器中的 go 语句之后时,它工作正常,没有错误。为什么会出现这样的行为呢?
I have a table on which there is update trigger written it has print statement before go statement.
ALTER TRIGGER user_type_check ON user_table --code PRINT 'Modification of user is done.' GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
Now with this structure whenever i perform update operation on the table it failed.
However when i moved the PRINT statement after the go statement in the trigger its working fine without error. Why is such a behavior ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看到实际上可能在您的主题中产生错误的代码会更有趣。 PRINT 不太可能产生此类错误。
为什么在触发器中使用 PRINT 而不是 RAISERROR?你想达到什么目的?
顺便说一句,当您将 PRINT 移到 GO 之后时没有收到错误的原因是它不再位于触发器定义中
Would be more interesting to see the code that actually could produce the error in your subject. PRINT is unlikely to generate such error.
Why are you using a PRINT in a trigger instead of a RAISERROR? What are you trying to achieve?
Btw, the reason why you don't get an error when you move the PRINT after the GO is that it is then no longer in the trigger definition