When it comes to SQL type conversions, we know that SQL is a weakly typed language, so you can do an implicit coercion type conversion, and the following is a record of the type conversion problems encountered in these days.
1. In sql, conversion between string types and numbers does not require coercion of type conversions, and if the string is a numeric string, it is converted directly to a numeric type, otherwise an error will be put.
2. In SQL, if a field data type is a character type, you must add ' (single quotation marks), unless the numeric value is numeric.
3. In SQL, there is an interesting phenomenon if datetime type data is not enclosed in single quotation marks, the system will give a default time.
There are also two types of conversion functions in SQL:
1.CAST (expression as data_type)
2.CONVERT (Data_type, Expression,[style])
SQL if the + number on both sides of the number and string type of two data, then the numeric addition processing, if the string type can not be forced to convert to a number, then an error.
Select 1+'a'
This code fragment will have an error that should be correct as follows:
Select ' a '+cast (1asChar(1))Select'A '+convert (char(1),1)
Type conversions for SQL