473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

SQL 2005 trigger Help

Hello
I have 2 tables, Journal and Config

Journal holds fields AssetTag, TransferFrom, TransferTo
Config holds AssetTag, CustID

I cannot figure out how to create a trigger that when a record is inserted into Journal, the trigger finds the record in Config with the matching AssetTag and updates Config.CustID with the data from Journal.TransferTo

(AssetTag is unique in Config table)
Jun 7 '07 #1
1 1727
this is hwatt i came up with anyone see any flaws? it seems to work as i want it to

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go




ALTER TRIGGER [monitorJournal]
ON [dbo].[Journal]
AFTER INSERT, UPDATE
AS
SET NOCOUNT ON;
IF (select AssetTag from inserted) <> '' AND (select transferTo from Inserted) <> '' AND (select transferToCustType from Inserted) <> ''
BEGIN
UPDATE dbo.config
SET CustID = (select transferTo from inserted), CustType = (select TransferToCustType from inserted)
Where Asset_Tag = (select AssetTag from inserted)
END
Jun 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: R.A.M. | last post by:
Hello, I am learning SQL Server 2005. I need to create a trigger which increments number of book's publications: CREATE TRIGGER InsertPublication ON Publications AFTER INSERT AS BEGIN
3
by: jdprime | last post by:
Hi, I am trying to write a trigger that will run when someone updates the delivery charge within the specified table. It will work, but will only record one change to the table. My question is, if...
0
by: sheenaa | last post by:
Hi Everyone, I m using ASP.NET 2005 with C# and SQL SERVER 2005. I m using stored procedure and sql datasource control to retrieve the data. I want to use the trigger...
1
by: Stout | last post by:
Is it possible to create a trigger in one database, that after an insert, will update a database on a different server? If so, how would I do this? Thanks. Bill
0
by: dmaier | last post by:
Below is a trigger that was working in SQL 2003 but will not work in Server 2005. All the fields are the same. Any help would be greatly appreciated. Dan USE GO /****** Object: Trigger . ...
1
by: Zeljko Bilandzija | last post by:
Hello! I have a problem, and I looking for help if someone can handle this. I use asp.net 2.0, and I create web site which support users from internet (Web Site Administration Tool) and with...
0
by: chris | last post by:
I've written a C# trigger on Developer_Box, using VS 2005 Professional. I need to deploy it on Test_Server, running SQLServer 2005. It compile fine, and the references to the appropriate...
11
by: tracy | last post by:
Hi, I really need help. I run this script and error message appeal as below: drop trigger log_errors_trig; drop trigger log_errors_trig ERROR at line 1: ORA04080: trigger 'LOG_ERRORS-TRIG'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.