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
 Old Forums
 CLOSED - General SQL Server
 Stored Procedure to run one SP, if no data found run a second SP

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-10-21 : 08:32:24
Paul writes "Hi guys

I have an eCommerce system that currently uses an inefficient query to link a products table to a table of discounts which relate to a group of products for each customer and calculates their net price.

The owner now wants to include a second discount structure which can link some (or maybe all) of the products (over 34000!!!) with a customer to get a special discount, but will retain the previous grouped discounts.

I have the system interrogating fairly well by first searching the products table for a description or part number, the customer clicks on the one he wants and gets a more details page which displays his net price - the page first runs a query against the partnumber discounts table, if nothing is found is displays the results of the group discount search which will always have a result. I use this method as otherwise an enormous array is needed to hold a correlation between each products unique key, the customer key, and the discount value from each of the two discount tables.

My problem is the owner wants the net price displayed on the first search results page. I have created four stored procedures which return results fairly quickly on their own, but they need to be paired to get one result set on my display page. What I need is a search for a partnumber discount, more often than not there won't be a result so I need the second query/SP to run to find the group discounted price. How do I get a stored procedure to run the first query, stop if it finds results and display its cursor, or run the second query and use its cursor?

HELP!!!"

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-10-21 : 23:54:15
Please post your tables, some sample data, your queries and the results you expect.

Go to Top of Page
   

- Advertisement -