Skip to content Skip to sidebar Skip to footer

Sql Server. Why Field Value Of [almost] Any Type May Be Treated As Quoted String In Query/dml?

I discovered SUDDENLY that in SQL Server (2000) any field type value may be treated as quoted string (in query or DML). Question: Is it normal behavior or accidentally successful

Solution 1:

If you check the CAST and CONVERT topic, you'll find a handy table:

enter image description here

You'll note that conversion fromchar and varchar is supported for every other type, and only a few of them require explicit casts. For some types, there's no obvious way to type a literal of that type, so allowing implicit conversions from a string makes sense.

(But oh, how I wish conversion to datetime required an explicit case with a format code...)

Post a Comment for "Sql Server. Why Field Value Of [almost] Any Type May Be Treated As Quoted String In Query/dml?"