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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Conditional Update

Author  Topic 

OldMySQLUser
Constraint Violating Yak Guru

301 Posts

Posted - 2009-09-10 : 05:41:26
I have two tables:

Table A
-------
id int
name varchar

Table B
-------
itemid int
description varchar

I am creating a script to update table A.

But, I also want to update table B if the id (type: identity) of the record from table A being updated is the max of the id column.

In this way table B will only be updated if the record being updated in table A is the latest record.

How can I do this please?

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-09-10 : 14:19:18
You could create a trigger (Insert?, Update) on table A that had the logic you mentioned which updates table B conditionally.

=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)
Go to Top of Page
   

- Advertisement -