Solved

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

Posted on 2008-06-24
1
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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 backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

696 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