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)
 Update table by stored proc with cursor

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-25 : 08:48:14
Steve writes "Hello folks,

Here's the problem:

I have a temporary table (basketuploads) with jobid, filename, userid. I have a main table (jobs) with jobid, userid, reportname, jobstatus.

I need to update the main table by setting jobs.reportname = basketuploads.filename, jobs.jobstatus = '6' where jobs.jobid = basketuploads.jobid and jobs.userid = basketuploads.userid
I then delete all records for that userid.

The problem is that I need to loop thru the table. How do I do this with a cursor?

I have the following stored proc:

==================

CREATE PROCEDURE AdminBasketClearDetails
@SessionID VarChar(50)

AS

set nocount on

declare @userid varchar(50)
declare @labID Int


set @userid = (select locationemail from userlog where sessionid = substring(@SessionID,1,40))


update Jobs
set JobStatus = 6

where JobID
in (
select JobID
from BasketUploads
)

Delete From BasketUploads
Where UserId = @UserID
GO

======================


I'd appreciate it greatly if you could help with this one.

Cheers,

Steve"
   

- Advertisement -