在SQL Server 2008中更新触发器 [英] update trigger in sq l server 2008

查看:98
本文介绍了在SQL Server 2008中更新触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

专家
我有2个表:dbo.posts(UserID,PostID,IsDelete,...)和dbo.Users(UserID,PostBody,PostCount,...)
我想编写一个触发器,当我编辑表帖子并将isdelete从false更改为true时,我的dbo.users.postcount将转换为dbo.users.postcount ++
反之亦然,如果我将isdelete从true更改为false,我的dbo.users.postcount将转换为dbo.users.postcount--
非常感谢您.

hi experts
i have 2 table :dbo.posts(UserID,PostID,IsDelete,...) and dbo.Users(UserID,PostBody,PostCount,...)
i want write a trigger that when i edit table posts and i change isdelete from false to true my dbo.users.postcount will converts to dbo.users.postcount++
and vice versa if i change isdelete from true to false my dbo.users.postcount will converts to dbo.users.postcount--
thank you so much

推荐答案

您需要先自己尝试一下.如果遇到困难,请分享您的问题.

您可以从此处了解触发器:
MSDN:创建触发器(Transact-SQL) [ ^ ]
MSDN:探索SQL Server触发器 [触发器简介-第一部分 [触发器-Sql Server [
You need to try out by yourself first. If you get stuck, do share your issue.

You can learn about triggers from here:
MSDN: CREATE TRIGGER (Transact-SQL)[^]
MSDN: Exploring SQL Server Triggers[^]
An Introduction to Triggers -- Part I[^]
Triggers -- Sql Server[^]

Try!


这篇关于在SQL Server 2008中更新触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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