Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimization with a date condition
Message
From
22/03/2011 17:21:31
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Title:
Optimization with a date condition
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01504587
Message ID:
01504587
Views:
91
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
Next
Reply
Map
View

Click here to load this message in the networking platform