[dba-SQLServer] SQL Server LIKE and non-string data types

Susan Harkins ssharkins at gmail.com
Sun Jan 20 13:06:50 CST 2008


I expected the following statement to fail

USE AdventureWorks
SELECT ProductID, Weight
FROM Production.Product
WHERE Weight LIKE '4%'

But it works. The documentation implies that LIKE won't work with non-string 
data types and that you must use CAST to convert them first -- but this 
works as expected without CAST. Weight is a decimal data type. I'm using SQL 
Server Express (2005) so I'm wondering if this is a version thing -- maybe 
2005 forces an implicit conversion?

Susan Harkins 




More information about the dba-SQLServer mailing list