Advertisement

08.29.2008 at 10:25AM PDT, ID: 23689512
[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!

8.1

SQL stored procedure

Asked by YRKS in SQL Server 2005

I have a table
TableA
id    parent_id   Desc
a
b
c            e
d
e
f             a
g

I want to filter out all the results from this table which just show b,c,d,f,g
since e and a are parents I do not want to select the.

I have a function which checks for this

wether it is a parent-- 0 = false, 1 = true
-- =============================================
Alter FUNCTION  isParent
(
@id char(15)
)
RETURNS  tinyint
AS
BEGIN
      
      -- Return the result of the function
      RETURN  (
            CASE WHEN (SELECT COUNT(id) from tableA where parent_id = @id) = 0
                        THEN 0
                        ELSE 1
                  END      
                  )
END

This function is called from a stored procedure which returns a table variable.

It all works fine. When we have a few records now we have 60000 records and everytime to check if it is a parent I am taking one record and going through 60000 records. The procedure takes 40 minutes to run.

I thought would create a temp table and check the ISParent function against records which have parents_Id but if I create a temp table in stored procedure my function cannot access it.

If I create a temp table in IsParent I get cannot create temp table in a function.

I need help in taking  the IsParent function and writing it in form of a SQL statement such that I can access the temp table in the stored procedure and donot use the IsPArent function or any other suggestions.

Thanks YRKSStart Free Trial
[+][-]08.29.2008 at 10:27AM PDT, ID: 22347504

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.29.2008 at 11:03AM PDT, ID: 22347788

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.29.2008 at 11:04AM PDT, ID: 22347801

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.29.2008 at 11:05AM PDT, ID: 22347808

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.30.2008 at 08:09AM PDT, ID: 22352187

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.02.2008 at 08:54AM PDT, ID: 22368449

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.02.2008 at 10:00AM PDT, ID: 22369155

View this solution now by starting your 7-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: SQL Server 2005
Sign Up Now!
Solution Provided By: chapmandew
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628