[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

multiple INDEXES for one table???

Posted on 2006-05-26
3
Medium Priority
?
185 Views
Last Modified: 2006-11-18
How do I choose and use one of the 3 indexes that I see assigned to a SQL Svr 2000 table?

M
0
Comment
Question by:MIKE
  • 2
3 Comments
 
LVL 71

Expert Comment

by:Éric Moreau
ID: 16771525
Hi CRXIuser2005,

Normally you don't need to specify any. The SQL engine decides which one is best to use.    

Cheers!
0
 
LVL 17

Author Comment

by:MIKE
ID: 16771553
hum.... well it's not decide correctly yet.

I created this FUNCTION.

and it is not returning the correct LIT TYPES because of the INDEXING of the table.

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


--------------------------------------------------------------------------------------------------------------------------
--Function to identify Litigation Types for Crystal Reporting
--Created by Mike Vega
--LIT COMPLETED =  TR/RR  + CR/PF/PS/OE  + RC    
--LIT STARTED =       TR/RR  +  CR/PF/PS/OE  + NO RC
--LIT REVIEW =          TR/RR, NO RC,PF,PS,CR,OE
--NO LIT NEEDED =   TR/RR/RC NO CR,PF,PS,OE
--LIT MISC =               ALL OTHER COMBINATIONS
-----------------------------------------------------------------------------------------------------------------------------

ALTER   function dbo.GetLitigationType ( @FileNumber varchar (40) , @Subject_Code varchar(10))
RETURNS VARCHAR(30)
AS
BEGIN
  declare @count_tr int
  declare @count_rr int
  declare @count_rc int
  declare @count_pf int
  declare @count_ps int
  declare @count_cr int
  declare @count_oe int
 
  select @count_tr =sum(1) from dbo.RLS where [File Number] = @FileNumber and [Subject Code] =@Subject_Code and [Activity Code] = 'TR'
  select @count_rr = sum(1) from dbo.RLS where [File Number] = @FileNumber and [Subject Code] = @Subject_Code and [Activity Code] = 'RR'
  select @count_rc = sum(1) from dbo.RLS where [File Number] = @FileNumber and [Subject Code] = @Subject_Code and [Activity Code] = 'RC'
  select @count_cr = sum(1) from dbo.RLS where [File Number] = @FileNumber and [Subject Code] = @Subject_Code and [Activity Code] = 'CR'
  select @count_ps = sum(1) from dbo.RLS where [File Number] = @FileNumber and [Subject Code] = @Subject_Code and [Activity Code] = 'PS'
  select @count_pf = sum(1) from dbo.RLS where [File Number] = @FileNumber and [Subject Code] = @Subject_Code and [Status Code] = 'PF'
  select @count_oe = sum(1) from dbo.RLS where [File Number] = @FileNumber and [Subject Code] = @Subject_Code and [Status Code] = 'OE'

 IF (@count_tr >0 and @count_rr >0 and @count_rc >0 and (@count_cr=0 or @count_pf=0 or @count_ps=0 or @count_oe=0))
   RETURN ('NO LIT NEEDED')
  IF (@count_tr>0 AND @count_rr >0 AND @count_rc >0 and (@count_pf>0 or @count_cr >0 or @count_ps >0 or @count_oe >0) )
   RETURN ('LIT COMPLETED')
  IF (@count_tr>0 AND @count_rr >0 AND (@count_rc =0 or @count_pf>0 or @count_cr >0 or @count_ps >0 or @count_oe >0))  
   RETURN ('LIT STARTED')
  IF (@count_tr >0 and @count_rr >0) --and (@count_rc=0 or @count_cr=0 or @count_pf=0 or @count_ps=0 or @count_oe=0))
   RETURN ('LIT REVIEW')
   RETURN ('LIT MISC')
END





GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

0
 
LVL 71

Accepted Solution

by:
Éric Moreau earned 1500 total points
ID: 16772473
Indexes have nothing to do with results! There are used to return results faster or as constraints (unique, ...).

If you call your SP from Query Analyzer, do you get good results?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

613 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question