You are here: Re: Passing DateDiff rather than Actual Dates as Parameters « MsSQL Server « IT news, forums, messages
Re: Passing DateDiff rather than Actual Dates as Parameters

Posted by Erland Sommarskog on 10/16/05 11:33

laurenq uantrell (laurenquantrell@hotmail.com) writes:
> Maybe you're right but it's pretty bullet proof and passing integers
> seems preferable to passing strings.

And binary values are even better. You should not pass dates as strings
to SQL Server. You should pass them as datetime values.

> I imagine this would have implications on query performance as well
> since the stored procedures would be using DECLARE'd variables as WHERE
> filters (WHERE StartDate BETWEEN @ServerStartDate and @ServerEndDate...)

Yes, if these are local variables and not parameters, SQL Server cannot
do parameter sniffing on them, but will apply standard guesses.

One way to circumvent this is to have a wrapper SP which unpacks the
integer values, and then call an inner SP which have datetime parameters.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация