Hi,
I have noticed that implicit casts are allowed according to the actual data in a column.
Here is an example:
MyColumn is defined as nvarchar(15) not null in the database schema.Code:SELECT * FROM MyTable WHERE MyColumn = 3897
This query will work only if there are no record in MyTable for which MyColumn has an alphanumerical value. Otherwise it will raise an error:
Serveur : Msg 245, Niveau 16, État 1, Ligne 1
Syntax error converting the nvarchar value 'C061' to a column of data type int.
Of course, the following query is always successful:
Code:SELECT * FROM MyTable WHERE MyColumn = '3897'
Am I correct?
Thanks a lot.


Reply With Quote