What is a convert function in database?
What is a convert function in database?
In SQL Server, the Convert function converts an expression from one datatype to another datatype.
Syntax:
- The syntax for the CONVERT function in SQL Server (Transact-SQL) is:
- CONVERT (type [ (length) ], expression [ , style ] )
Type:
- The datatype that you wish to convert expression to and it can be one of the following are:
bigint, int, smallint, tinyint, bit, decimal, numeric, money, smallmoney, float, real, datetime, smalldatetime, char, varchar, text, nchar, nvarchar, ntext, binary, varbinary, or image.
Length:
- Optional. The length of the resulting data type for char, varchar, nchar, nvarchar, binary and varbinary.
Expression:
- The value to convert to another datatype.
Style:
- Optional. The format used to convert between datatypes, such as a date format or string format. It can be one of the following values:
Example:
Let's look at some SQL Server CONVERT function examples and explore how to use the CONVERT function in SQL Server (Transact-SQL).
For example:
SELECT CONVERT(int, 14.85);
Result: 14 (result is truncated)
In SQL Server, the Convert function converts an expression from one datatype to another datatype.
Syntax:
- The syntax for the CONVERT function in SQL Server (Transact-SQL) is:
- CONVERT (type [ (length) ], expression [ , style ] )
Type:
- The datatype that you wish to convert expression to and it can be one of the following are:
bigint, int, smallint, tinyint, bit, decimal, numeric, money, smallmoney, float, real, datetime, smalldatetime, char, varchar, text, nchar, nvarchar, ntext, binary, varbinary, or image.
Length:
- Optional. The length of the resulting data type for char, varchar, nchar, nvarchar, binary and varbinary.
Expression:
- The value to convert to another datatype.
Style:
- Optional. The format used to convert between datatypes, such as a date format or string format. It can be one of the following values:
Example:
Let's look at some SQL Server CONVERT function examples and explore how to use the CONVERT function in SQL Server (Transact-SQL).
For example:
SELECT CONVERT(int, 14.85);
Result: 14 (result is truncated)
Share This with your friend by choosing any social account
You may also read following recent articles
![]() |
Is Chat GPT Use Of Web Content Fair!
Junaid A 29-Jan-2023 |
![]() |
Office politics examples!
Junaid A 28-Jan-2023 |
![]() |
ten jokes about the status of ChatGPT!
Junaid A 17-Jan-2023 |
![]() |
Image Resizing On Uploadig!
shahid Riaz 02-Jan-2019 |
![]() |
Hosting Server Connect Timeout!
Junaid A 13-Apr-2018 |
![]() |
What I can do after BS!
12-Apr-2018 |
|
Best hosting for windows!
05-Apr-2018 |
![]() |
Why cv is rejected!
30-Mar-2018 |
|
How to Integrated The Theme in Project!
shaheer 27-Mar-2018 |
![]() |
How to perform crud operations in asp.net?!
27-Mar-2018 |
![]() |
How to perform crud operations in asp.net?!
27-Mar-2018 |
![]() |
What is outer join in database?!
Arsal Ahmed 20-Mar-2018 |
![]() |
What is right join in database?!
Arsal Ahmed 20-Mar-2018 |