Solved

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

Posted on 2008-06-24
1
208 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Attaching Database Failed ? 3 39
SQL Help 27 42
VBScript Write Column Headers 3 35
ms sql + get number in list out of total 7 26
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

786 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