Comments on: SQL Server 2000 date and time puzzler http://www.xaprb.com/blog/2005/12/04/sql-server-2000-date-and-time-puzzler/ Stay curious! Thu, 02 May 2013 12:36:53 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Xaprb http://www.xaprb.com/blog/2005/12/04/sql-server-2000-date-and-time-puzzler/#comment-3936 Xaprb Tue, 06 Feb 2007 22:26:23 +0000 http://www.xaprb.com/blog/?p=51#comment-3936 It’ll actually depend on the system, and especially if it’s in a stored procedure, the values passed for the first invocation will determine the query plan, which will then get stored and used for future calls — even if they should be optimized differently. You can defeat that though if you need to.

If the query plan is re-compiled every time, (@param is null or col = @param) is a better idea.

]]>
By: Chris http://www.xaprb.com/blog/2005/12/04/sql-server-2000-date-and-time-puzzler/#comment-3934 Chris Tue, 06 Feb 2007 19:25:42 +0000 http://www.xaprb.com/blog/?p=51#comment-3934 I’m wondering about the table-scan-ness of ISNULL alternatives. I understand that passing in @parameter and doing:

ISNULL(@parameter, columnName) will cause the table scan.

Your alternative is looking for nulls in the columns. What about if the null is in the paremter?

Will:

… where (@parameter is null or column = @parameter

perform better?

Thanks!

]]>