LEARN BUILD GROW TOGETHER
Practical knowledge for developers
DEVELOPER LEARNING HUB
Learn. Build. Grow Together.

Practical tutorials, real-world examples and interview preparation.

.NETC#SQL SERVERANGULAR
Home /Sql-Server /Differences between CAST() and CONVERT() Functions

Differences between CAST() and CONVERT() Functions

August 10, 2022 5 min read

 

# CAST() and CONVERT() Functions

The CAST and CONVERT functions are both used to convert data from one data type to another.

SELECT CAST ('10' as int) * 20;        --outpout=200

SELECT CONVERT (int, '10') * 20;       --outpout=200 

In both cases, we’re converting from the text value ’10’ to its integer representation. 


  • In many ways CAST and CONVERT are similar. Both are used to convert data from one type to another.  Thought their syntax is different, both functions are able to convert values from one formation to another.
  • CAST is part of the ANSI-SQL specification; whereas, CONVERT is not.  In fact, CONVERT is SQL implementation-specific.

No comments:

Post a Comment