SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
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
   SET
      sal1_desc = @sal1_desc
,     sal2_desc = @sal2_desc
,     lsal_desc = @lsal_desc
...to replace what you've posted.

-PatP
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000