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 one row out of multiple rows 1

Status
Not open for further replies.

henin

MIS
Oct 30, 2007
35
IL
Hi everyone,
I wrote a script to update a table as follows:
Code:
IF EXISTS(SELECT * FROM contsupp WHERE accountno='95376')
  BEGIN
    UPDATE contsupp
    SET recommend='2'
    WHERE
    accountno='95376'
  END
ELSE
  BEGIN
    INSERT INTO contsupp
    (accountno,recid,recommend)
    SELECT
    '1','1','1'
  END
The problem is: there are multiple records with accountno:'95376'. I want only one row to be updated, say, that with maximum date value ("mydate" column). Can any one tell me how to do that?
Thanks
 
Try doing a "Search" on "maximum date value"

< M!ke >
[small]"Oops" is never a good thing.[/small]
 
Sure it does...I tried it just before posting to make sure.

Timing is everything, though! ;-)



< M!ke >
[small]"Oops" is never a good thing.[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top