Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Trigger HELP

Status
Not open for further replies.

RaineSpencer

Programmer
May 8, 2002
25
US
Hi -
I need to create an insert trigger that will insert a record into another table (B) when a record is added to table (A). I need to insert both static values for some columns and values from the inserted table...for instance I need the regdate of the new record in table A in column 1, a "4" in column two, the amount from the new record in table A in column 3, a "P" in column 4, etc.

How can I do this???

TIA,
Lorraine
 
This should work for you. Understand that you cannot really test this in the Query Analyzer since the INSERTED table only exist within the trigger.


CREATE TRIGGER [TRIGGER NAME] ON [dbo].

FOR INSERT
AS
insert into table2 (col1, col2, col3,col4)
select regdate,4,amount,'P' from Inserted



Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top