Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date range question. 2

Status
Not open for further replies.

sparkbyte

Technical User
Joined
Sep 20, 2002
Messages
879
Location
US
Which query would be better??

Code:
Select Tracking_ID, EmployeeID, MachineName, BoxNumber, FileNumber, TrackingDate
FROM tblTrackingTable

WHERE     (TrackingDate BETWEEN DATEADD(dd, DATEDIFF(dd, 0, CURRENT_TIMESTAMP), 0) AND CURRENT_TIMESTAMP)

AND			FileNumber NOT LIKE '.box.end.'

ORDER BY	TrackingDate DESC

STATS said:
Number of SELECT statements 1 1.0000
Rows returned by SELECT statements 107 107.0000
Number of server roundtrips 1 1.0000
Bytes sent from client 600 600.0000
Bytes received from server 13310 13310.0000
Client processing time 31 31.0000
Total execution time 1546 1546.0000
Wait time on server replies 1515 1515.0000


OR

Code:
DECLARE @Today DATETIME
SET @Today = GETDATE()

-- Remove the time element
SET  @Today = DATEDIFF(DAY, 0, @Today)

Select 
	  Tracking_ID
	, EmployeeID
	, MachineName
	, BoxNumber
	, FileNumber
	, TrackingDate
FROM	tblTrackingTable
WHERE	TrackingDate >= @Today
AND		TrackingDate < @Today + 1
AND		FileNumber NOT LIKE '.box.end.'
ORDER BY	TrackingDate

STATS said:
Number of SELECT statements 4 4.0000
Rows returned by SELECT statements 110 110.0000
Number of server roundtrips 3 3.0000
Bytes sent from client 914 914.0000
Bytes received from server 31722 31722.0000
Client processing time 32 32.0000
Total execution time 1578 1578.0000
Wait time on server replies 1546 1546.0000

This table will grow on average of 10k to 20k rows per day.


Thanks

John Fuhrman
 
Thanks Mark!!

Thanks

John Fuhrman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top