Hi All,
I have been working with SQL Server for some time - but until now
haven't tried to implement a trigger and am not sure if this is an
appropriate use. Any advice would be greatly appreciated.
I have this table: almis.dbo.aadata_x
when almis.dbo.aadata_x is updated, I want to automatically be able to
update a table in another database using this sql (only pulling
specifics from this table - not everything):
insert into dbname.dbo.tablename
select stfips as statefips, right(area, 3) as countyfips, periodyear,
race, gender, cenoccgrp, population, laborforce, emplab, unemp,
unemprate, pctpop, pctlabforce, pctemplab, pctunemp, pcttotlabforce,
pcttotemplab, pcttotunemp from aadata_x
where areatype = 04 and periodyear = 2000
and stfips = 18
I apologize in advance if this is too basic of a question -- but this is
something I need to be able to do in many cases .. on update of table1
.. update certain fields in another table - perhaps in the same
database, perhaps not.
Again - thanks for any input you might be able to give me.
B
*** Sent via Developersdex http://www.developersdex.com *** 1 1153
Bethany Holliday wrote: Hi All,
I have been working with SQL Server for some time - but until now haven't tried to implement a trigger and am not sure if this is an appropriate use. Any advice would be greatly appreciated.
I have this table: almis.dbo.aadata_x
when almis.dbo.aadata_x is updated, I want to automatically be able to update a table in another database using this sql (only pulling specifics from this table - not everything):
insert into dbname.dbo.tablename select stfips as statefips, right(area, 3) as countyfips, periodyear, race, gender, cenoccgrp, population, laborforce, emplab, unemp, unemprate, pctpop, pctlabforce, pctemplab, pctunemp, pcttotlabforce, pcttotemplab, pcttotunemp from aadata_x where areatype = 04 and periodyear = 2000 and stfips = 18
I apologize in advance if this is too basic of a question -- but this is something I need to be able to do in many cases .. on update of table1 . update certain fields in another table - perhaps in the same database, perhaps not.
CREATE TRIGGER trigger_name
ON table
AFTER UPDATE
AS
insert into dbname.dbo.tablename
select stfips as statefips, right(area, 3) as countyfips, periodyear,
race, gender, cenoccgrp, population, laborforce, emplab, unemp,
unemprate, pctpop, pctlabforce, pctemplab, pctunemp, pcttotlabforce,
pcttotemplab, pcttotunemp
from aadata_x
where areatype = 04 and periodyear = 2000 and stfips = 18
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matik |
last post by:
Hello to all,
I have a small question.
I call the SP outer the DB. The procedure deletes some record in table
T1.
The table T1 has a trigger after delete.
This is very importand for me, that the SP will be finished ASAP,
that's why, I do not want, and I do not need to wait for a trigger.
|
by: Scott CM |
last post by:
I have a multi-part question regarding trigger performance. First of
all, is there performance gain from issuing the following within a
trigger:
SELECT PrimaryKeyColumn FROM INSERTED
opposed to:
SELECT * FROM INSERTED
|
by: Martin |
last post by:
Hello,
I'm new with triggers and I can not find any good example on how to
do the following:
I have two tables WO and PM with the following fields:
WO.WONUM, VARCHAR(10)
WO.PMNUM, VARCHAR(10)
WO.PROBLEMCODE, VARCHAR(8)
|
by: Mary |
last post by:
We are developing a DB2 V7 z/OS application which uses a "trigger"
table containing numerous triggers - each of which is activated by an
UPDATE to a different column of this "trigger" table. When the
triggers are fired, various other operations are performed on other
tables in the database. The triggers are not created on these other...
|
by: Dave Sisk |
last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table.
(Note this is an external trigger defined with the ADDPFTRG CL command, not
a SQL trigger defined with the CREATE TRIGGER statement.) I've also defined
a SQL stored proc, and the trigger is set to call this SP. I've posted the
simplified source below. I can...
| |
by: JohnO |
last post by:
Thanks to Serge and MarkB for recent tips and suggestions.
Ive rolled together a few stored procedures to assist with creating
audit triggers automagically. Hope someone finds this as useful as I've
found it educational.
Note:
- I build this for use in a JDEdwards OneWorld environment. I'm not
sure how generic others find it but it...
|
by: deepdata |
last post by:
Hi,
I am creating a trigger in DB2 express version.
When i use the following syntax to create trigger
CREATE TRIGGER USER_PK_TRIGGER
BEFORE INSERT On users
REFERENCING NEW As N
FOR EACH ROW
|
by: Ots |
last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app.
I have an Audit trigger that logs changes to tables. I want to apply
this trigger to many different tables. It's the same trigger, with the
exception of the table name. I could manually change the table name in
the trigger and create it, over and over, but I'd like to automate...
|
by: Shane |
last post by:
I have been instructed to write a trigger that effectively acts as a foreign
key. The point (I think) is to get me used to writing triggers that dont
use the primary key(s)
I have created the following trigger
create trigger chk_team
on teams
for insert as
declare @chkCountry as char(2)
|
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' does not exist
drop table log_errors_tab;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |