SQL 触发器一次 1 行
我正在创建一个如下所示的更新触发器(SQL Server 2005):
该行的状态列是 23 还是 25,请勿更新它。不然更新一下吧这很简单。我正在尝试
OldState = (Select State from Deleted)
If OldState in (25,23)
Update it --how to do it easily?
else
dont do nothing for this row
问题是触发器是用所有更新的行调用的,所以删除是一个集合,这意味着第一条指令将不起作用,因为它试图仅获取 1 个值,但它得到了一个集合
。这么简单,我错过了什么吗?
非常感谢
I'm creating an update trigger that goes like this (SQL Server 2005):
Is the state column of the row is 23 or 25 don't update it. Else update it. It's very simple. I'm trying
OldState = (Select State from Deleted)
If OldState in (25,23)
Update it --how to do it easily?
else
dont do nothing for this row
The problem is that the trigger is called with all the updated rows, so deleted is a set, that means the first instruction won't work because it's trying to get only 1 value and it gets a set..
It's something so simple, am I missing something?
Thank you very much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此代码假设:
示例:
This code assumes:
Example: