Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

How to set index for these select queries Expand / Collapse
Author
Message
Posted Friday, January 18, 2013 3:00 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:30 PM
Points: 41,531, Visits: 34,448
prakash.kumar3669 (1/17/2013)
GilaMonster (1/17/2013)
Index on (IsDeleted, SubmitDate DESC) include (ProdName,Category,TotalStock,Price)

What would be the exact sql query to create the index.


Why don't you open up books online and read over Create Index.

btw, that's a rather odd predicate on the date column...

how can you ellaborate ?


SubmitDate>=' ' and SubmitDate<' '


There is no possible way that any date can be both greater than or equal to '' and less than ''. Let me rephrase that into numbers...

WHERE SomeNumber >=0 AND SomeNumber < 0

That's completely, logically impossible as it is only true for a number that's both positive and negative at the same time, which no number is.

Either you mis-typed when you copied the query over, or there's some serious flawed logic at work.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1408779
Posted Friday, January 18, 2013 4:06 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, January 18, 2013 10:46 AM
Points: 7, Visits: 19
WHERE SomeNumber >=0 AND SomeNumber < 0

this is the actual condition: SubmitDate>=DATEADD(day,DATEDIFF(day,0,GETDATE()),@duration) AND SubmitDate < DATEADD(day,DATEDIFF(day,0,GETDATE()),1)
Post #1408806
Posted Friday, January 18, 2013 4:08 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, January 18, 2013 10:46 AM
Points: 7, Visits: 19
@duration is negative number....like -1,-2,-3
Post #1408807
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse