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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query to compare

Status
Not open for further replies.

Deam

Programmer
Oct 10, 2000
68
US
I am trying to create a stored proc that would compare the value entered by a user with the value in another table.
There are two tables Table_a(PersonID,ALocationCode,AFlag) and Table_b(PersonID,BLocationCode)
If the ALocationCode entered by the user is not equal to the BLocationCode then AFlag needs to be checked. I am new to this...any help is appreciated.
 
Try this one...

update Table_a
set AFlag = 'YES' -- or set to TRUE, whatever you want
where PersonID IN (
select B.PersonID
from Table_A A, Table_B B
where A.PersonID = B.PersonID and
A.ALocationCode <> B.ALocationCode
)
Andel
andelbarroga@hotmail.com
 
I don't believe I understand what you want to do, but I think you might want to do it with a trigger for update, insert on Table_A vice a stored proc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top