Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

808 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