J.A. Coutts
Systems Engineer
Edsonet/TravPro
**************** REPLY SEAPRATER ******************
At 12:01 AM 10/08/2000 -0700, you wrote:
>But once again, its all about the query. For example, lets say you have
>an index on calldate. If you want to delete records older than 24
>hours,
>you could (although bad) do this:
>
>Delete From Calls
>Where DateDiff(d, GetDate(), CallDate) > 1
>
>However, this is VERY expensive, since it has to compare every record
>and compute the difference. However, its better to do this:
>
>DECLARE @deldate datetime
>Select @deldate = DateAdd(d, -1, GetDate())
>Delete From Calls Where CallDate < @deldate
>
>What this does is figure out the date ahead of time (which, all dates
>are just numbers) and can use the index to find the candidates. There
>is
>no computation with every record and can speed up select/delete calls
>incredibly.
>
>--
>
>Dale E. Reed Jr. Emerald and RadiusNT/X
>__________________________________________
>IEA Software, Inc. www.iea-software.com
>
For more information about this list (including removal) go to:
http://www.iea-software.com/support/maillists/liststart