Sql 简明教程

SQL - Conversion Functions

在 SQL 中, conversion functions 用于将值从一个数据类型转换为另一个数据类型。通常,函数名称的形式遵循数据类型到数据类型的约定。第一个数据类型是输入数据类型。第二个数据类型是输出数据类型。

In SQL, the conversion functions are used to convert a value from one datatype to another. Generally, the form of the function names follows the convention datatype TO datatype. The first datatype is the input datatype. The second datatype is the output datatype.

List of Functions

以下是 SQL Server 中可用于将一种数据类型转换为另一种数据类型的一系列函数 −

Following is a list of functions available in the SQL server for Conversion of one datatype to another −

Sr.No.

Function & Description

1

CASTIs used to transform the numerical data into character or string data.

2

CONVERTIs used to transform an expression from one data type to another.

3

PARSEIs used to convert a string data to the desired data format and returns the outcome as an expression.

4

TRY_CASTIs used to return the expression in the chosen data type.

5

TRY_CONVERTIs used to change the datatype of an expression.

6

TRY_PARSEIs used to return a result of an expression that has been converted to the specified data type, or NULL if the conversion is unsuccessful.