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)
 Where clause for Update Statement

Author  Topic 

Trudye
Posting Yak Master

169 Posts

Posted - 2008-08-06 : 07:01:39
Hey Guys, I have to update the last rec in a table. The only way to identify this record by the FileNum field. The last record written to this table has the max filenum.

SET @RecCount = (SELECT COUNT(LNAME) FROM dbo.My_File)
update tblProcess_Dates
Set RecCount = @RecCount
where FileNum = MAX(FileNum)
I'm not sure how to write my WHERE statement, any ideas?

Thanx,
Trudye

bjoerns
Posting Yak Master

154 Posts

Posted - 2008-08-06 : 07:04:40
where FileNum = (
select max(FileNum)
from tblProcess_Dates
)
Go to Top of Page

Trudye
Posting Yak Master

169 Posts

Posted - 2008-08-06 : 08:27:00
aaaah! a subquery in the WHERE statement, Too Cool.

Thanks so much,
Trudye
Go to Top of Page
   

- Advertisement -