[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Multiple SQL statements in a single stored procedure

Asked by k3opie in MS SQL Server

Tags: stored, multiple, procedure, queries, single

Got a little bit of an design question for all you sql experts.  I'm looking for a little more info then a simple yes or no.  
Here goes.

My co-worker and I are working with a rather large MS SQL 2005 DB.  We have a table that contains about 12 fields with the key made up of a single field.  One of the fields is named IsActive, as you can imagine this field is a BIT that lets us know if the current record is considered active or inactive.  When writing a stored procedures we considered various approaches.

1.) writing two stored procedures, one to query on a parameter @IsActive and one SP to return All records regardless of IsActive (i.e. IsActive = 0 or 1.)

2.) writing a single sp to get all data and filter on the other end of the pipe.

3.) writing a single sp that accepts @IsActive and defaults to NULL .. if NULL then the sp splits on an IF statement to execute a query that gets all data, If @IsActive is 0 or 1 then executes a query to match the @IsActive bit.

What we think of each solution:
Solution 1 isn't good for use because it *2 the number of sp's needed to write for the table.

Solution 2 isn't good because it sends a lot of extra data over the pipe.

Solution 3 isn't good because the DBMS can't optimize the sp properly since it contains various queries and splits on IF THEN logic.


I'm curious what you guys have done, experienced, learned in the past when dealing with a situation like this.
Thanks guys, looking forward to your input.
Andrew

[+][-]12/13/06 07:39 AM, ID: 18131263Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: MS SQL Server
Tags: stored, multiple, procedure, queries, single
Sign Up Now!
Solution Provided By: aneeshattingal
Participating Experts: 4
Solution Grade: A
 
[+][-]12/13/06 07:39 AM, ID: 18131266Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/06 07:41 AM, ID: 18131283Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/06 07:41 AM, ID: 18131286Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/06 07:49 AM, ID: 18131358Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/13/06 11:36 AM, ID: 18133337Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/13/06 10:37 PM, ID: 18137002Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/06 10:51 PM, ID: 18137048Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/13/06 11:56 PM, ID: 18137228Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy