Teradata REPLICATE function?

2.6k views Asked by At

I'm converting MS SQL Server codes to Teradata. I found out that Teradata has no replicate function. Below is the sample code

REPLICATE('0',2-LEN(CAST(COLUMN_NAME AS NVARCHAR)))

Is there an alternative function for replicate in Teradata?

Thanks

2

There are 2 answers

4
Tim Biegeleisen On BEST ANSWER

Try this:

SUBSTR('00', 1, 2-CHARACTER_LENGTH(CAST(COLUMN_NAME AS VARCHAR(10)))

This will repeat the character '0' two minus the length of the column, which is effectively doing the same thing as REPLICATE in SQL Server.

1
access_granted On

General equivalent would be:

select LPAD('0', needed_length, '0');