Could anyone help me understand why the following query works fine in SQL 2000 and not in SQL 2005
In SQL 2005 it errors out "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value"
DECLARE @Table table(date varchar(6),code char(1))
INSERT INTO @Table select '010209','N'
INSERT INTO @Table select '032809','N'
INSERT INTO @Table select space(6),'N'
select * FROM @Table
WHERE
(
(
date <> ''
AND
GETDATE() < CAST(LEFT(date, 2) + '/' + SUBSTRING(date, 3, 2) + '/' + RIGHT(date,2) AS SMALLDATETIME)
)
OR code = 'Y')