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.
| Author |
Topic |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2007-02-27 : 17:59:48
|
| I have a code like below...@startdate is datetime data typeand service_date_thru is varchar..Even though, these two data has a different data type, the query is still returing the right result...Can you compare varchar to datetime? Is it becaue SQL server is doing a data conversion implicitly?I am just curious????declare @startdate datetimedeclare @enddate datetimeset @startdate = '1/1/2007'update revenue_stageset inperiod = case when @startdate <= service_date_thru then 1 when @startdate > service_date_thru then 0else NULL end |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-02-27 : 19:05:29
|
| Yes, SQL Server is doing a data conversion implicitly, converting the data type with the lower precedence to the data type of the higher precedence. In your case, a DATETIME data type has a higher precedence than a VARCHAR so your VARCHAR date value is implicitly converted to DATETIME.SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
|
|
|