3 réponses
- Le plus récent
- Le plus de votes
- La plupart des commentaires
1
I have fixed this by adding an If condition.
This is what worked for me: select IF(LENGTH(employee_id)<8,LPAD(employee_id,8,'0'),employee_id) from table1
répondu il y a un an
0
The third argument is expected to be a string for LPAD function - can you pelase try it like this?
select LPAD(CAST(employee_id As varchar),8,'0') as EmployeeID
répondu il y a un an
0
Thank you for your response. I tried this last night and found a problem with Lpad function. Its prefixing the 0's however, its also truncating the string if the string size is more than the size of the padding we give. Just wondering if there is any way we can avoid truncating.
select lpad(employee_id,8,'0') from table1 --> This is prefixing 0's to employee id less than 8 however its also truncating employee ids more than 8 characters.
Example: 123456 --> 00123456 123456789012 --> 12345678
répondu il y a un an
Contenus pertinents
- demandé il y a un an
- demandé il y a 2 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 3 ans