为什么使用Trigger而不是SP? [英] Why use Trigger instead of SP?

查看:97
本文介绍了为什么使用Trigger而不是SP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下触发器的问题。我知道触发器是特殊类型的SP,但为什么我们使用触发器而不是SP。

如果触发器用于某种目的,那么我们可以在sp中做同样的事情吗?为什么不使用SP。

解决方案

当您在表格上执行插入/更新/删除时,会自动调用(执行)触发器



存储过程需要手动调用(按需)


这将让你了解触发器

触发器 - Sql Server [ ^ ]



并查看此链接也可用于触发器与SP



http:/ /technet.microsoft.com/en-us/library/ms189550(v=sql.105).aspx [ ^ ]



http://stackoverflow.com/questions/2088905/pros-and-cons-of-triggers-vs-stored-procedures-for-denormalization [ ^ ]

I want to ask the question about trigger. I know triggers are special type of SP,but why we we use trigger instead of SP.
If trigger is using for some purpose then we can do same in sp? Why not using SP.

解决方案

Trigger is automatically invoked (executed) when you do a insert/update/delete on a table

Stored procedure needs to be called manually(on demand)


This will give you idea about triggers
Triggers -- Sql Server[^]

and see this links also for triggers vs SP

http://technet.microsoft.com/en-us/library/ms189550(v=sql.105).aspx[^]

http://stackoverflow.com/questions/2088905/pros-and-cons-of-triggers-vs-stored-procedures-for-denormalization[^]


这篇关于为什么使用Trigger而不是SP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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