Languages
[Edit]
EN

MS SQL Server - CAST() function example

0 points
Created by:
Inferio
328

In this article, we would like to show you CAST() function example in MS SQL Server.

Quick solution:

SELECT CAST(value AS DATA_TYPE);

Note:

Go to the official documentation to see available DATA_TYPES.

Practical example

In this example, we will convert INT value to CHAR type using CAST() function.

Query:

SELECT CAST(100 AS CHAR) AS 'int_to_char';

Result:

MS SQL Server - CAST() function example
MS SQL Server - CAST() function example

Note:

Go to this article to see how to convert columns using CAST() function.

Related post

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

MS SQL Server - functions

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join