Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 ISNULL

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2008-08-13 : 13:47:50
Working with two tables.

IMITMIDX_SQL
OEORDLIN_SQL

if userfld3 is updated or changed in the imitmidx_sql I want to look at the oeordlin_sql and anywhere userfld5 is null populate it with imitmidx_sql.userfld3. I've tried the following in a trigger and it does not seem to work.



CREATE TRIGGER [UPDATEoeordlinuserfield5ifnull] ON [dbo].[imitmidx_sql]
for INSERT, update
AS

update oeordlin_sql
set oeordlin_sql.user_def_fld_5 = inserted.user_def_fld_3
from inserted join oeordlin_sql on inserted.item_no = oeordlin_sql.item_no
where oeordlin_sql.user_def_fld_5 = null

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-13 : 13:50:32
[code]CREATE TRIGGER [UPDATEoeordlinuserfield5ifnull] ON [dbo].[imitmidx_sql]
for INSERT, update
AS

update o
set o.user_def_fld_5 = i.user_def_fld_3
from inserted i
join oeordlin_sql o
on i.item_no = o.item_no
where o.user_def_fld_5 is null[/code]
Go to Top of Page
   

- Advertisement -