0
CAST and CONVERT SQL Server 2005
Posted by Rajendra Prasad Panchati
on
Wednesday, June 16, 2010
Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.
Syntax
Using CAST:
CAST ( expressionAS data_type ) Using CONVERT:
CONVERT ( data_type [ ( length ) ] ,expression [ ,style ] )Arguments
expressionIs any valid Microsoft® SQL Server™ expression. For more information, see Expressions.
data_typeIs the target system-supplied data type, including bigint and sql_variant. User-defined data types cannot be used. For more information about available data types, see Data Types.
lengthIs an optional parameter of nchar, nvarchar, char, varchar, binary, or varbinary data types.
styleIs the style of date format used to convert datetime or smalldatetime data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types), or the string format when converting float, real, money, or smallmoney data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types).
More
Less