SQL Server implicitly converting date-like VARCHAR to datetime

327 views Asked by At

I have a column in a table named Foo called Bar. It's defined as a varchar(10) not null. The content of that column for the record I am looking at is Jan 1 1900 12:00AM -- remember, this is a varchar(10), not a datetime. But when I do a SQL query (in Query Analyzer) of something like SELECT Bar FROM Foo I get 1900-01-01 00:00:00.000 This means that SQL is somehow implictly converting the varchar to a datetime. This is becoming a problem because i have a query that uses the exact value of lots of columns to identify them, and when they're automatically being converted to datetimes, it screws everything up. What's going on here and how do I keep SQL Server (I think it's sql server!) from doing this implicit conversion to datetime?

0

There are 0 answers