sql检测更新触发器中修改的字段(sql server 2005)? [英] sql to detect fields modified in update trigger ( sql server 2005 )?

查看:101
本文介绍了sql检测更新触发器中修改的字段(sql server 2005)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在sql server 2005中,在更新触发器内可以找到由原始更新查询修改的字段列表-列。

In sql server 2005 , inside an update trigger is there a way to find the list of fields\columns those are modified by the original update query.

I有一个包含150列的表,并且在触发器内部需要知道是否仅更新了一个特定字段(并且没有修改其他字段)

I have a table with 150 columns and inside the trigger need to konw if ONLY one particular field was updated or not ( and no-other field was modified )

我可以写一个长的sql比较150列,但是它很容易出错并且看起来很愚蠢!

I can write a long sql to compare 150 columns but it will be error prone and look stupid!

任何解决该问题的方法都不错。我希望可以使用一些sql2005 api。

Any decent way of getting around this problem. I am hoping some sql2005 api will come to my rescue.

推荐答案

COLUMNS_UPDATED -有点麻烦,但是您应该可以根据需要轻松地使用它。在 SQL Server Central 上有一篇不错的文章。

Take a looksie at COLUMNS_UPDATED - it's a bit of a pain, but you should be able to work with it quite easily for your requirement. There's a decent article about it on SQL Server Central.

这篇关于sql检测更新触发器中修改的字段(sql server 2005)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆