Reputation: 301
I want to add leading spaces in one of the column of the table. This ID column has data type Char(6).
Example: Table1
ID
1234
5678
when I do select * from Table1. and save file into .csv with pipeline delimited. It show spaces at the end of number.
Current output:
|1234 |
|5678 |
desired output
| 1234|
| 5678|
Upvotes: 0
Views: 8081
Reputation: 231681
You'd need to trim
the value to remove the trailing spaces and then lpad
it to add the leading spaces
select lpad(trim(id),6)
from your_table
Here is a sqlfiddle example that shows the steps
Upvotes: 3