Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Padding on extra characters.

Status
Not open for further replies.
Sep 25, 2000
18
US
I need to update data in a column by adding on a variable number of characters. The number of characters that I have to add on is dependent upon how many characters are already there. The data in this column varies between 5-7 characters and I need to get each record in that column to 12 characters (all zeros to the left of what's already there). I was planning on doing this by using the LPAD function.

Is there an easy way to do this for the entire column, not just one record at a time? Thanks in advance. I'll buy you a beer. erick@cmoremedical.com
 
update <table_name>
set <column_name>=
concat(
substr('000000000000',1,12-length(<column_name>)),
<column_name>
)
/

I prefer Old Rasputin Russian Imperial Stout from North Coast Brewing...

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top