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 2000 Forums
 SQL Server Development (2000)
 Use of MAX(column_name) in a Stored Procedure

Author  Topic 

lutis2
Starting Member

2 Posts

Posted - 2005-01-21 : 16:35:45
Hello!

I'm trying to run an Update Stored Procedure whitch would update the newest date only from a date column to today's date, but somehow it seems that I'm not allowed to use MAX(column_name) to get the newest date. Please, is there anyone who would be able to give me a clue of how to make it work? I'm writing the stored procedure on a webpage through Dreamweaver MX and here is my code:

UPDATE dbo.Mileage
SET MAX(ToDate) = getDate()
WHERE MAX(ToDate) < getDate()

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-01-21 : 16:44:06
UPDATE dbo.Mileage
SET ToDate = GETDATE()
WHERE ToDate = (SELECT MAX(ToDate) FROM dbo.Mileage)

Tara
Go to Top of Page

lutis2
Starting Member

2 Posts

Posted - 2005-01-24 : 12:42:10
Thank you, thank you! It worked just as I wanted!
Go to Top of Page
   

- Advertisement -