Implicit cast
An implicit cast governs what automatic data conversion occurs for an operation that involves two different data types. All casts between built-in data types are implicit.
The database server automatically invokes an implicit cast when
it performs the following tasks:
- It passes arguments of one data type to a UDR whose parameters are of another data type.
- It evaluates expressions and needs to operate on two similar data types.
Conversion of one data type to another can involve loss of data. Be careful of creating implicit casts for such conversions. The end user cannot control when the database server invokes an implicit cast and therefore cannot avoid the loss of data that is inherent to such a conversion.
The database server invokes an implicit cast automatically, without a cast operator. However, you also can explicitly invoke an implicit cast with the CAST AS keywords or the :: cast operator.
To create an implicit cast, specify the IMPLICIT keyword of the
CREATE CAST statement. The following CREATE CAST statement creates
an implicit cast from the percent data type to the DECIMAL
data type:
CREATE IMPLICIT CAST (percent AS DECIMAL)