Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

There is a Table contains 10 Lacs Records

IMEIInfo(PkID,IMEI1,IMEI2,IMEI3,IMEI4,CreateDate)

I Search Here by IMEI1,IMEI2,IMEI3,IMEI4
AS

<sql>
SQL
SET STATISTICS TIME,IO OFF

DECLARE     @IMEI VARCHAR(50)='6655465465465465'
DECLARE     @IMEI2 VARCHAR(50)=NULL
DECLARE     @IMEI3 VARCHAR(50)=NULL
DECLARE     @IMEI4 VARCHAR(50)=NULL


IF  EXISTS(SELECT 1 FROM ModelIMEI(NOLOCK) MI
WHERE
(@IMEI<>'' AND @IMEI IS NOT NULL AND( MI.IMEI=@IMEI OR MI.SecondaryIMEI=@IMEI OR MI.IMEI3=@IMEI OR MI.IMEI4=@IMEI))
OR
(@IMEI2 <>'' AND @IMEI2 IS NOT NULL AND( MI.IMEI=@IMEI2 OR MI.SecondaryIMEI=@IMEI2 OR MI.IMEI3=@IMEI2 OR MI.IMEI4=@IMEI2))
OR
(@IMEI3 <>'' AND @IMEI3 IS NOT NULL AND (MI.IMEI=@IMEI3 OR MI.SecondaryIMEI=@IMEI3 OR MI.IMEI3=@IMEI3 OR MI.IMEI4=@IMEI3))
OR
(@IMEI4 <>'' AND @IMEI4 IS NOT NULL AND (MI.IMEI=@IMEI4 OR MI.SecondaryIMEI=@IMEI4 OR MI.IMEI3=@IMEI4 OR MI.IMEI4=@IMEI4))
)
BEGIN
SELECT 'IMEI Already Exists'
RETURN
END


How can I Fast this query

Thanks
shreeniwas
Posted

1 solution

Hi,

Use Indexes...

You can't do anything with query but you can create indexes and increase the performance of the query.

Defining Indexes with SQL Server 2005[^]


Overview of SQL Server 2005/2008 Table Indexing (Part-1)[^]
 
Share this answer
 
Comments
shreeniwas kushwah 30-May-13 8:07am    
How can I show Plan and Time of Execution etc info in sql server (to view data searching after creating Indexes)
Rockstar_ 30-May-13 8:09am    
Check with once SQL server Profiler in tools menu of SSMS.
shreeniwas kushwah 30-May-13 8:42am    
OK Now how analysing query by profiler ???

Please tell me??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900