var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: SQL Server equivalent for DATE LIKE '%__/Apr/2006%' (was "Please Give Me A Hand...")
I'm happyguy and this is the first time to post my problem. Thanks a lot
here is a SQL query that I know how to write in Oracle, which is
Select * from AttandanceRecord where date like '%__/Apr/2006%'
but, now i'm developing my system with using Ms Sql Server 2000, so I don't know how to write a query with same output as above...
Please, can somebody help me??
There are several ways to reproduce the query you've posted and have it work in SQL Server, but all of those ways suffer from a number of problems. A minor re-write could yield:
...which performs much better.
WHERE '1 Apr 2006' <= date
AND date < '1 May 2006'
Another cool way
What Pat suggested is more secure, this is another way it can be done
I have used this query against the Northwind db which is default with MSSQL:
select * from employees where datepart(month,birthdate)=12 and datepart(year,birthdate)=1948
Should get one record with name Nancy.
BEWARE SQL has DATETIME datatype, both in one.
Using datepart() throws any indexes out the window.
What does that mean, please explain.
"throws indexes out the window" means the index (if any) on the birthdate column will be ignored, and the query will use a table scan instead of an index lookup as it would with pat's query (post #2)
That makes sense.