473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Using Trigger to populate another table

Hi all,
I have two tables tbl_A and tbl_B.
Table Definitions:
tbl_A (field_1, field_2, field_3)
tbl_B (field_1, field_2)
I would like to populate tbl_B when a record is inserted into tbl_A.
Note that tbl_A.field_1 = tbl_B.field_1 and tbl_A.field_2 =
tbl_B.field_2 .

How do I write a trigger on tbl_A to get the corresponding record
inserted into tbl_B?

Regards
June.....
Jul 20 '05 #1
2 4564
Try

Create trigger tbl_AIns on tbl_A
for Insert as
begin
INSERT tbl_B
Select field_1
, field_2
from INSERTED
End

HTH,
Srinivas Sampangi
"June Moore" <ju******@yahoo.com.au> wrote in message
news:e5**************************@posting.google.c om...
Hi all,
I have two tables tbl_A and tbl_B.
Table Definitions:
tbl_A (field_1, field_2, field_3)
tbl_B (field_1, field_2)
I would like to populate tbl_B when a record is inserted into tbl_A.
Note that tbl_A.field_1 = tbl_B.field_1 and tbl_A.field_2 =
tbl_B.field_2 .

How do I write a trigger on tbl_A to get the corresponding record
inserted into tbl_B?

Regards
June.....

Jul 20 '05 #2
Hello June !

Try this

The statement in the trigger is:

Insert into table2
Select field_1,field_2 from inserted

Jens Süßmeyer.

"June Moore" <ju******@yahoo.com.au> schrieb im Newsbeitrag
news:e5**************************@posting.google.c om...
Hi all,
I have two tables tbl_A and tbl_B.
Table Definitions:
tbl_A (field_1, field_2, field_3)
tbl_B (field_1, field_2)
I would like to populate tbl_B when a record is inserted into tbl_A.
Note that tbl_A.field_1 = tbl_B.field_1 and tbl_A.field_2 =
tbl_B.field_2 .

How do I write a trigger on tbl_A to get the corresponding record
inserted into tbl_B?

Regards
June.....

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sjaak van Esdonk | last post by:
Hi all, i'm trying to find a solution for the following problem: I have two different database called A and B. On database A runs an application call AA. Some information from the database A...
3
by: Luklrc | last post by:
Hi. I have a problem I hope someone can help me with. I have a database of events. Each event has a date and a duration (days). What I need to do is to be able to display search for events...
2
by: gustavo_randich | last post by:
Hi :-) I'm porting a project from Oracle to DB2 and now I'm trying to avoid error SQL0746N in a trigger which reads the same table in which the trigger is defined. Below is Oracle's...
2
by: mike | last post by:
I have a SQL based ERP package. Now I am having an issue on a particular table of people deleting a record (in the ERP system) and no one having any idea of who did it or when. So I thought I...
6
by: Jchick | last post by:
Im a newbie with a sql table in a MSDE database that contains fields of CustName, BrokerName, Type, Status. I am trying to write a trigger that does this: 1. When a new record in a table is...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
0
by: Jabba007 | last post by:
I have an update trigger on a table called 'tbl_br' that is used to audit column changes and populate those changes into an audit table called 'tbl_audit'. See an excerpt of the code below: ...
2
by: potti | last post by:
Hi, I am inserting data in table1.using a trigger I want to populate TABLE2.My code is like this : TABLE1 :ST_INFO FIELDS : NAME (varchar),ACCOUNT_TYPE(varchar),TIME(date) TABLE2 :TOTALS FIELDS...
3
by: lenygold via DBMonster.com | last post by:
Thank you very much SERGE for your help. I found example in Graeme Birchall COOKBOOK wich i think exactly what i need for SQL check in triggers: • User query joins to table function - sends...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.