+ 2
Is there a padleft in sql ?
I have a database field which I want to use in a view. Other programs will retrieve data from this view. The data in this field is 4 or 5 characters wide. It need to be 5 characters all the time. Is there something like pad left in SQL (not Trans-act or MySql) 12345 is ok 1234 needs to be 01234 1323 needs to be 01323 0 if the characters which is gone be used to fill up the string.
3 Answers
+ 2
Sorry could not wait so googled a bit more
http://www.tech-recipes.com/rx/30469/sql-server-how-to-left-pad-a-number-with-zeros/
SELECT FORMAT (salary, '000000') FROM emp;
This did the trick.
0
Hey what's a padleft
0
Fill a string to a certain length, with a specific character.
padleft adds this character to the beginning of the string.
padright adds this character to the end of the string.