Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Between & < = operators;

Author  Topic 

Hariarul
Posting Yak Master

160 Posts

Posted - 2006-08-09 : 09:02:08
Hi ,

In a stored procedure when retrieving records based on a DATETIME values in WHERE clause - can we use BETWEEN clause or Col <= AND Col >= ?

Please suggest which is the optimised way.

Thanks in Advance,

Hari Haran Arulmozhi

Q
Yak Posting Veteran

76 Posts

Posted - 2006-08-09 : 09:22:32
You can use them both. I think the best way is Between ... AND ...
Go to Top of Page

sqlghost
Starting Member

23 Posts

Posted - 2006-08-09 : 10:07:18
Regarding: BETWEEN clause or Col <= AND Col >= ?

SQL Server internally resolves the BETWEEN operator to a comparison of >= and <= .So, there's really no valid point in using BETWEEN clause.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-09 : 11:38:06
At least you can reduce using coloumn name twice if you use Between

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2006-08-09 : 11:56:29
quote:
Originally posted by madhivanan

At least you can reduce using coloumn name twice if you use Between



Yes, but then it takes longer to correct it to >= and <, which is probably what it should be.
Go to Top of Page
   

- Advertisement -