0

I got trouble to give space between words on sql, before on sql I already did on vb.net:

'============================= Create Space Between Words ========================'
'Split The Words into 3 line'
' Lang if 0 english else if 1 Indonesian'
Dim ReceiptTextWords As String() = receiptText.Split("+")
'================================== First Line ==================================='
' This is how the third line appears in the string array after the space splitting'
Dim ReceiptTextWord1 As String() = ReceiptTextWords(0).Split(" ")
' This array contains the spaces reserved for each word in the string array above'
If lang = "0" Then
    ' MM YY : 0610 REF. NO : 1234567890 R.WAHYUDIYONO,IR  '
    Dim spaces1 = New Integer() {3, 10, 2, 16, 5, 7, 2, 16, 29}
    ' Now loop on the strings and format them as indicated by the spaces'
    ' Attention, the value for space include the string itself'
    Dim z As Integer = 0
    For Each s In ReceiptTextWord1
        sb.Append(s.PadRight(spaces1(z)))
        z += 1
    Next
ElseIf lang = "1" Then
    ' BL TH : 0610 NO REF. : 1234567890 R.WAHYUDIYONO,IR '
    Dim spaces1 = New Integer() {3, 9, 2, 17, 3, 11, 2, 17, 29}
    ' Now loop on the strings and format them as indicated by the spaces'
    ' Attention, the value for space include the string itself'
    Dim z As Integer = 0
    For Each s In ReceiptTextWord1
        sb.Append(s.PadRight(spaces1(z)))
        z += 1
    Next
End If

But right now I should do it on sql.

Right no on my stored procedure, I give the space manually and set in on char variable:

SET @ReceiptText = '                               NO REF.    : '+@RefNo+'                                                                                                                                      MOHON SIMPAN STRUK INI    ,          SEBAGAI             BUKTI PEMBAYARAN YANG SAH    '

I thought it's quite annoying, is there any solutions? Or what I've done on vb.net could resolve on sql?

SysDragon
  • 9,692
  • 15
  • 60
  • 89
Sabilv
  • 602
  • 1
  • 15
  • 44
  • Perhaps this might help you: http://stackoverflow.com/questions/121864/most-efficient-t-sql-way-to-pad-a-varchar-on-the-left-to-a-certain-length – Tom F May 16 '13 at 11:01
  • Can you show the value of `receiptText` (the input) and the desired output? – Matt Wilko May 16 '13 at 12:46
  • @MattWilko here's the example MM YY : 0610 REF. NO : 1234567890 R.WAHYUDIYONO,IR the input output should like my last question : http://stackoverflow.com/questions/16438159/give-specific-space-on-string – Sabilv May 17 '13 at 02:51

0 Answers0