I’m using MS SQL, and my query is like this:
select
A.CUS_EuroCustId No_Id,
' ' BLANK1,
A.IVC_Number INV_Nr ,
' ' BLANK2,
'PINV' PINV ,
' ' BLANK3,
from
INVOICE as A
Then the output is like this:
01102450 146918 PINV
01102847 146381 PINV
01105915 16151 PINV
01102646 146850 PINV
01105915 16150 PINV
The IVC_Number has two format, 6 digits and 5 digits and the space between IVC_Number and ‘PINV’ is important. Now how can I make it in my SQL query and the output should be like this:
01102450 146918 PINV
01102847 146381 PINV
01105915 16151 PINV
01102646 146850 PINV
01105915 16150 PINV
Thanks.
Use
LEFTand add some padding yourself:And it will always be 6 characters wide.
Although, of course, in the current query, each column should be being displayed separately anyway – something is combining all of the columns together into a single piece of text, and I’d usually recommend pushing string formatting out to whatever that component is, rather than working in SQL.