Please start any new threads on our new site at 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)
 Avoiding cursors when working on the output of executed stored procs

Author  Topic 

Ask SQLTeam Question

0 Posts

Posted - 2004-09-14 : 08:22:20
Doug writes "The 3rd party application I'm working on is using cursors extensively. I would like to find a set based solution to this problem.

I am wanting to perform an update to the first and last name of a customer and then insert this customer_no into a temp table

I then want to update the salutation table for these modified customer name that exisit in my temp table by firing off the application's provided stored procedure which returns the salutation pieces.

This is the way it is done currently using the application's own cursor approach

<Inner operation of the cursor which loops through each customer one by one>

Insert #sals
Exec BUILD_SAL @customer_no = @customer_no

Select @sal1_desc = sal1_desc,
@sal2_desc = sal2_desc,
@lsal_desc = lsal_desc
From #sals

Update salutation
Set sal1_desc = @sal1_desc,
sal2_desc = @sal2_desc,
lsal_desc = @lsal_desc
Where customer_no = @customer_no

Pat Phelan
Posting Yak Master

187 Posts

Posted - 2004-09-14 : 14:09:46
While it appears that there has to be a lot of code that you didn't post, you could use:
UPDATE salutation
sal1_desc = @sal1_desc
, sal2_desc = @sal2_desc
, lsal_desc = @lsal_desc replace what you've posted.

Go to Top of Page

- Advertisement -