Groups | Blog | Home
all groups > sql server new users > september 2006 >

sql server new users : Update only top 20 rows in a table


Daves
9/19/2006 12:00:00 AM
how can I update only top 20 rows in a table? The table consists of

PostlistID int,
UserID int,
Send_Begin datetime,
Send_End datetime

and what I'm doing is to sequentally
-grab next 20 rows of recipients and set Send_Begin to GetDate()
-send these users email
-update Send_End to GetDate()
- ...etc...

Roger Wolter[MSFT]
9/19/2006 8:02:53 AM
With SQL Server 2005 you can use TOP in the update statement to do this:
http://msdn2.microsoft.com/en-us/library/ms180971.aspx
Otherwise, you would have to use a where clause with a subquery I suppose.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

[quoted text, click to view]

AddThis Social Bookmark Button