Original: http://www.2cto.com/database/201310/250880.htmlSQL cast and CONVERT usage detailed Summary: The following applies only to Mysqlselect {fn CONCAT (CONVERT (User_id,char), user_name)} as Str from T_SYS_ User following this applies only to
Get data type:1. If you want to see the value and type of an expression, use Var_dump ().2. If you just want an easy-to-read type of expression for debugging, use GetType ().3. To view a type, do not use GetType () and use the Is_type ()
GrammarUse CAST:
CAST (expression as data_type)
Use CONVERT:
CONVERT (data_type[(length)], expression [, style])
ParametersExpression
Is any valid Microsoft SQL Server expression. For more information, see expressions.
Data_type
The data
SyntaxUse CAST:
CAST (expression AS data_type)
Use CONVERT:
CONVERT (data_type [(length)], expression [, style])
ParametersExpression
Is any valid Microsoft SQL Server "expression. For more information, see expressions.
Data_type
The data types
Both cast and convert in SQL Server convert an expression from one data type to another data type. Because SQL Server provides two features, it can be confusing to choose which feature should be chosen or in which case the feature should be used.
In the project, the float type is used to define some columns, such as price, but many problems are found.1. When the number of bits on the value is greater than 6, the float type is converted to the varchar type, which is displayed in the
1.sqlserver CAST and CONVERT functionsExplicitly converts an expression of a data type to another data type. CAST and CONVERT provide similar functionality.GrammarUsing CAST:CAST (expression as data_type)Using CONVERT:CONVERT (data_type[(length)],
Document directory
Data Type Conversion
Data Type Conversion
In Transact-SQL, there may be two levels of data type conversion:
When the data of one object is moved to another object, or the data between two objects is compared or combined,
The use and difference of cast and convert in SQL more the/1/ -Source: SQL Learning Tour:14125Learning Tags:cast ConvertSQL This article guide: both cast and convert in SQL are expressions used to convert an expression of one data type to another
Cause: the cast method only supports reference and boxing conversions. Use select instead:
That is to say, the cast <> () method only supports packing and unpacking, and other forced type conversion is not supported.
For example, if you want to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.