CAST and CONVERT

CAST or CONVERT convert explicit a value form one data type to another.

SQL Syntax 1:
 
   CONVERT( datatype, expression [, style] )
SQL Syntax 2:
 
  CAST( expression AS datatype )
Parameters:
 
  expression
Any expression of any type.

datatype

The new data type. This parameter is not a expression.

style

A integer value for compatible with the MS SQL Server.

Escape Syntax:
 
  {fn CONVERT( expression, datatype )}
Return Type:
 
  definite with the parameter datatype.

Examples:

  • SELECT convert( varchar(30), price )
  • SELECT convert( nvarchar(30), now(), 102)
  • SELECT {fn convert( {fn now()}, nvarchar(30))}
  • SELECT cast( price as varchar(30)

see also:
SQL System Functions


100% pure Java DBMS
Mirror Site