In SQL Server, there are functions like TRIM, LTRIM, RTRIM to remove characters from a string. In Teradata, the equivalent is TRIM function.

Trim from leading zeros

The following code snippets remove leading zeros from the string literal.

select trim(leading '0' from '00012345000')

Result:

Trim(LEADING '0' FROM '00012345000')

1 12345000

Trim from trailing zeros

Similarly, TRIM function can also be used to remove trailing zeros:
select trim(trailing '0' from '00012345000')

Result:

Trim(TRAILING '0' FROM '00012345000')

1 00012345

Trim both leading and trailing zeros

select trim(both '0' from '00012345000')
Result:
Trim(BOTH '0' FROM '00012345000')
1 12345

Trim a column in a view or table

select trim(leading '0' from column_name) from table_name
select trim(trailing '0' from column_name) from table_name
select trim(both '0' from column_name) from table_name

Trim other characters

You can use TRIM function to trim all other characters by replacing '0' to the character you want to trim. 

select trim(leading 'A' from 'AAA2041145')
copyright This page is subject to Site terms.

More from Kontext

local_offer teradata local_offer SQL

visibility 9
thumb_up 0
access_time 11 days ago

The following code snippets show how to use round numbers to hundreds or thousands in Teradata.  warning Alert - The following code snippets are used to round to the smallest hundreds or thousands that is equal or greater than the i...

open_in_new Code snippets

local_offer teradata local_offer SQL

visibility 18
thumb_up 0
access_time 11 days ago

In article   Teradata SQL...

open_in_new Code snippets

local_offer teradata local_offer SQL

visibility 11
thumb_up 0
access_time 11 days ago

This page shows you how to use LIKE

open_in_new Code snippets

local_offer teradata local_offer python

visibility 1037
thumb_up 1
access_time 4 months ago

Pandas is commonly used by Python users to perform data operations. In many scenarios, the results need to be saved to a storage like Teradata. This article shows you how to do that easily using JayDeBeApi or  ...

open_in_new Spark + PySpark

comment Comments (0)

comment Add comment

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

No comments yet.

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.


Learn more arrow_forward