August 2012
Intermediate to advanced
1416 pages
33h 39m
English
Converting data from one data type to another data type is often handled automatically by SQL Server. Many of those conversions are implicit, or automatic.
Explicit conversions require a CAST() or CONVERT() function:
SELECT CAST('Away' AS NVARCHAR(5)) AS ‘Tom Hanks'
TOM HANKS --------- AWAY
SELECT CAST(123 AS NVARCHAR(15)) AS Int2String
INT2STRING --------------- 123
CONVERT (data type, expression[, style])
The style parameter usually refers to the optional date styles listed in Table 8.7. The style is applied to the output during conversion from datetime to a character-based data type, or to the input during conversion from text to datetime. Generally, the one- or two-digit style provides a two-digit year, and its ...
Read now
Unlock full access