Gurus Of the following two queries which one will execute faster Query 1 SELECT NoOfShr,ShrAmt from CUS_tShrInstLdgrHdr WHEREBrID = @p_BrIDAnd PrdID=@p_PrdIDAnd AcctID=@p_AcctIDAnd Busndt>=dbo.fSetBusnDate(@m_FDate)And Busndt<=dbo.fSetBusnDate(@m_TDate) Query 2 SELECT NoOfShr,ShrAmt from CUS_tShrInstLdgrHdr WHEREBrID = @p_BrIDAnd PrdID=@p_PrdIDAnd AcctID=@p_AcctIDAnd BusndtBetweendbo.fSetBusnDate(@m_FDate) dbo.fSetBusnDate(@m_TDate) Kindly assist Deep Regards Anil Never Give Up
They are equivalent, there is only minor syntax difference. It means between is internaly treated as <expression> <= <value from> and <expression> >= <value to>, so there will be no difference in execution plan.
As a sidenote: Don't use a UDF in your WHERE clause. This will almost certainly kill performance on larger tables. What is dbo.fSetBusnDate supposed to do? If it will just strip out the time portion from the data, see if this helps:http://www.sql-server-performance.com/fk_datetime.asp -- Frank Kalis Moderator Microsoft SQL Server MVP Webmaster:http://www.insidesql.de