Select DateField from table where Month(DateField) = 11 and Year(DateField)
= 2007 and Day(DateField) = 21
and
Select DateField from table where DateField = '20071121'
What should I use?
Thanks a lot!
The first will never use an index where as the second has a chance to use
one. Never use a function on a column in a WHERE clause if you can avoid it.
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Paulo" <prbspfc@.uol.com.br> wrote in message
news:%23FZmm3HLIHA.5360@.TK2MSFTNGP03.phx.gbl...
> Select DateField from table where Month(DateField) = 11 and
> Year(DateField) = 2007 and Day(DateField) = 21
> and
> Select DateField from table where DateField = '20071121'
> What should I use?
> Thanks a lot!
>
|||On Nov 22, 1:34 am, "Paulo" <prbs...@.uol.com.br> wrote:
> Select DateField from table where Month(DateField) = 11 and Year(DateField)
> = 2007 and Day(DateField) = 21
> and
> Select DateField from table where DateField = '20071121'
> What should I use?
> Thanks a lot!
If you used datetime variable then
Where
datecol>=dateadd(day,datediff(day,0,@.datevar),0) and
datecol<dateadd(day,datediff(day,0,@.datevar),1)
sql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment