Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Optimization with a date condition
Message
De
22/03/2011 17:21:31
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Titre:
Optimization with a date condition
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01504587
Message ID:
01504587
Vues:
92
If I have a script like this:
SELECT MyTable.MyField FROM MyDatabase.dbo.MyTable WHERE MyTable.AddDate>'2011/03/22 17:08:26'
...it executes instantly. The result is zero record.

But, if I parameterize it such as:
DECLARE @Date datetime

SET @Date='2011/03/22 17:08:26'

SELECT MyTable.MyField FROM MyDatabase.dbo.MyTable WHERE MyTable.AddDate>@Date
...it takes a while. And, the result is still zero record.

I tried to make the declaration char and nvarchar but that did not help.

There is something I am missing here.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform