sql server - Using a SQL function to pad strings with spaces -


is inefficient use user defined function pad spaces? have padding function i'd more intuitive using built in replicate function afraid introducing inefficiency code.

the padding must done in sql.

you can use right or left depending on paddibg direction.
example:

select right('11111' + originalstring, 5)  

this pad string on left 1s make 5 letters string. (i've used 1s instead of spaces easy read. spaces can use space function:

select right(space(5) + originlstring, 5) 

to pad right can this:

select left(originalstring + space(5), 5)  

or convert char suggested gordon linoff in comments


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -