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!

Select and update functions in one stored proc 1

Status
Not open for further replies.

abs2003

MIS
Aug 31, 2004
80
US
I don't know if this is possible.

1. select top 100 * from a table.
2. update field on a table as 'in-process' for all 100 records
3. pass those 100 records to my application.

all this has to be done in stored proc.

abs
 
It's possible.

Create Procedure GetSomeData
AS
SET NOCOUNT ON

Update MyTable
Set MyField = 'In-Process'
Where Idfield In (Select top 100 IdField From MyTable)

Select Top 100 * From Mytable


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I should mention that you should put an order by in the top 100 queries to ensure you are getting the right data.

Create Procedure GetSomeData
AS
SET NOCOUNT ON

Update MyTable
Set MyField = 'In-Process'
Where Idfield In (Select top 100 IdField From MyTable Order By SomeField)

Select Top 100 * From Mytable Order By SomeField


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top