View previous topic :: View next topic
|
Author |
Message |
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
Hi,
Table :
C1: Varchar(60)
C2: Char(02)
Current data in the table
Code: |
423< 10
424< 10
425< 10
00000426< 10
427< 10
00000429< 10
|
The requirement is to update the table column C1.
1. Select row and pad leading zeroes to make it 8 bytes wherever data in column C1 is less than 8 bytes (in example - 423)
2. Update all the rows in the table
Any help is much appreciated.
Thanks
TS70363 |
|
Back to top |
|
|
MOHAN KUMAR DURAIRAJAN
New User
Joined: 16 Apr 2012 Posts: 11 Location: INDIA
|
|
|
|
Hey TS70363 ,
This requirement is very simple. Need to find the length and need to do left padding.
Find the querry below. It will be helpful.
UPDATE TABLE NAME
SET COLUMN NAME = LPAD(COLUMN NAME,8,'0')
WHERE LENGHT(COLUMN NAME) < 8
Thanks,
Mohan |
|
Back to top |
|
|
|