Wednesday 20 September 2017

CAST and CONVERT (Transact-SQL)

Converts an expression of one data type to another.
For example, the following examples change the input datatype, into two other datatypes, with different levels of precision.+
SQL
SELECT 9.5 AS Original, CAST(9.5 AS int) AS int, 
    CAST(9.5 AS decimal(6,4)) AS decimal;
SELECT 9.5 AS Original, CONVERT(int, 9.5) AS int, 
    CONVERT(decimal(6,4), 9.5) AS decimal;

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive