We help IT Professionals succeed at work.

How do I Execute stored procedure and  if true(1) is returned Execute another stored procedure.

encoredatas
encoredatas asked
on
Medium Priority
220 Views
Last Modified: 2013-11-10
I have a stored procedure that loops through a list of Phone Numbers. The Stored Procedure returns 1 if the Phone Number is found on the table. If it is found I want to pass in the phone number ID one of the Package Level variable in the For Each Loop Container to the Second procedure to Flag another table. If it is not found I don't want to execute the second one but continue checking the next number in the loop. Thanks!
Comment
Watch Question

Have you considered using an UPDATE/JOIN to do this kind of work rather than doing it iteratively?
UPDATE DestinationTable
SET Flag = 1
FROM DestinationTable D, SourceTable S
WHERE D.Phone_Number  = S.PhoneNumber
Assuming the databases are on the same server this is going to be a lot simpler and a hell of a lot faster.

Author

Commented:
The table are on are on two different servers.
Is there any particualr logic in the stored procedures or are they just looking for phone numbers on one side and then inserting them on the other?
I don't want to get off track but basically even using a slow linked server will be quicker than looking phone numbers up one at a time and transferring accross.
Commented:
You want to to all the work in SSIS?
If true, simple add a SQL Task that calls a stored procedure with an output parameter that send the value to a SSIS variable, and use the expression and constraint between task to apply the condition you want.
Helped?
regards,
pedro
www.pedrocgd.blogspot.com

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks this really helped. save me lots of time. Thanks once again
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.