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

Stored proc question 1

Status
Not open for further replies.

MarkGreen

Technical User
Oct 4, 2002
40
0
0
GB
Hi,

What would the syntax to update a boolean field in the record that contains the highest value in an integer field.

I bascially need to set a flag in the record that has the highest ID.

I've looked in various resources but they dont seem to quite answer the questions that i need. For instance - Can you use "TOP" with "UPDATE"?
Any help is much appreciated :)
Mark
 
Can you not simply use MAX() whenever you need to know which is the highest valued?

HTH,

Graham
 
You could use something like this:

Code:
UPDATE table_name
SET IsHighest = 1
WHERE int_col = (SELECT MAX(int_col) FROM table_name)

Obviously if more than one row has the highest value, this will update them all. --James
 
Thanks James, I suspected it was something similiar but i couldnt quite get the syntax correct.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top