Solved

micrsoft, sql server, databases, trigger insert help req'd

Posted on 2008-06-24
1
204 Views
Last Modified: 2008-07-03
folks

If i have one object called PO and another called
receipts with a relational field of po.ponum=receipts.ponum i.e.

PO table      
ponum      
1      
2      

Receipts      
ponum      item
1      100
2      101

how do i build a trigger to fire an insert into another
table (postatus)to show that there been made inserts made
into the receipts table based on the ponum  i.e.

postatus      
ponum      date
1      gedate
1      getdate


all help will do
0
Comment
Question by:rutgermons
1 Comment
 
LVL 2

Accepted Solution

by:
pierky earned 500 total points
ID: 21855301
That's the trigger: when you insert a new record in Receipts a new record is added to postatus too.
CREATE TRIGGER trReceiptsInsert ON dbo.Receipts 

FOR INSERT

AS
 

INSERT INTO postatus ( ponum, inserted )

SELECT

	ponum, GETDATE()

FROM

	inserted

Open in new window

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now