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

Stuart McLachlan stuart at lexacorp.com.pg
Sun Jan 20 22:47:26 CST 2008


What documentation are you referring to? 

>From SQL Server 2000 BOL:

LIKE
.......
"If any of the arguments are not of character string data type, Microsoft® SQL 
ServerTM converts them to character string data type, if possible."

(Don't have v7 documentation available here, but I'm pretty sure it was the same back then.)

Cheers,
Stuart

On 20 Jan 2008 at 14:06, Susan Harkins wrote:

> 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 
> 
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
> 






More information about the dba-SQLServer mailing list