Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Right Padding - Add spaces or zeros at the end of the string in Teradata

Right Padding function is not readily available in Teradata but it can be acheived by computing the padding characters by substring function and adding them to the input string or column.

Sample Syntax:
SELECT 
SUBSTRING  'string' or column || ('characters to pad',1, length of characters to pad -LENGTH('string' or column))


Example:

Suppose we want to pad for a number 12 upto 5 characters(total) with zeros.
12 ------> 12***

SELECT 
'12' AS inputvalue, 
inputvalue || SUBSTRING('*****',1,5-LENGTH('12'))  AS after_padding

Remember, the number must be given as a string (should be in quotes)
Output:
inputvalueafter_padding
1212***


Suppose we want to pad for a string 'aa' upto 5 characters with zeros.
aa ------> 000aa

SELECT 
'aa' AS inputvalue, 
 inputvalue || SUBSTRING('*****',1,5-LENGTH('aa'))  AS after_padding


Output:
inputvalueafter_padding
aaaa***