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.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Avoiding cursors when working on the output of executed stored procs
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 09/14/2004 :  08:22:20  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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 - 09/14/2004 :  14:09:46  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000