Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

SQL
--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 


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 :)
Posted
Updated 4-Jun-12 17:15pm
v2

1 solution

Looks very new to triggers, Start your self to write a trigger here is the Link[^] where you can get some basic idea about the triggers with examples.

Here is the Google[^] Search for you to learn more about the Triggers

Thanks
--RA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900