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

问题描述



我是新来的触发器,我想问一下父表更新后如何自动更新子表.

我这里有表区域和表主列表

Hi,

I''m new to trigger, I would just like to ask how can I update the child table automatically when the parent table is updated.

I have here table area and table masterlist

--Area:
CREATE TABLE [dbo].[Area](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Area] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Area_1] PRIMARY KEY CLUSTERED 

--MasterList:
CREATE TABLE [dbo].[MasterList](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[FullName] [varchar](50) NOT NULL,
	[Area] [varchar](50) NOT NULL,
	[MeterNumber] [varchar](20) NOT NULL,
	[MeterType] [varchar](20) NOT NULL,
 CONSTRAINT [PK_MasterList_1] PRIMARY KEY CLUSTERED 



它们都具有相同的Area Area.

我想问的是,如果我更新了Table Area.Area,我想自动更新MasterList.Area.

非常感谢你.高度赞赏您的建议:)



they both have the same field Area.

What I would like to ask is, If I updated the Table Area.Area I would like to automatically update the MasterList.Area.

Thank you very much. Your suggestion is highly appreciated :)

推荐答案


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

10-24 10:22