TD_ConvertTo

TD_ConvertTo is a Teradata table operator used for converting the column data types of a source table to a new target data type. It is an efficient way to convert data types as its a set based operation thus avoiding row-by-row casting whilst leveraging Teradata's parallel AMP processing for efficiency.

A common use case is converting multiple columns to the same data type. For example multiple columns representing financial transactions can be converted to a consistent decimal format in one step (see example). TD_ConvertTo does not use explicit precision in the data type declaration in the SQL code, it uses internal precision defined by the function. So you declare ‘decimal’ and the function outputs values to decimal(38,19).

If you want to control precision and scale, then use CAST. TD_ConvertTo provides a quick way to transform columns to a consistent data type in bulk and a quick way to discover errors and issues with column data in scope for transformation.

TD_ConvertTo • Database Engine 20 In-Database Analytic Functions • Reader • Teradata Developers Portal

TD_ConvertTo example - you can define a TargetDataType for each TargetColumn but this example shows multiple string columns to decimal

example script: TD_ConvertTo.sql

Previous
Previous

TD_GetFutileColumns

Next
Next

String Similarity