Search code examples
sqlteradatareplicate

Teradata REPLICATE function?


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


Solution

  • 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.