Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating after row insert from same table ....

Status
Not open for further replies.

DWag

IS-IT--Management
Jan 28, 2003
25
US
Switching database formats and all existing triggers are being rewritten in sql. The following uses only one table and needs to look for the first match based on the first nine digits of item and then update certain fields in the new item created....


CREATE TRIGGER boardsize ON item
FOR INSERT
as

update itm

set itm.uf_cswidth = i.uf_cswidth

from item itm

join ( select distinct substring(item,1,9) from item where item.product_code like 'lam%' ) i
on substring(itm.item,1,9) = substring(i.item,1,9)


Thanks
Dedra
 
This would update all records not just the one(s) inserted.

In SQL Server triggers there are two virtual tables available, inserted and deleted. Which contain the records just inserted, or deleted or changed (changed uses both virtual tables, old record in deleted and new record in inserted).

Are you getting an error message right now or is it simply not doing what you want?



Questions about posting. See faq183-874
 
Just not working...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top