Oracle function LPAD to MSSQL
Results 1 to 3 of 3

Thread: Oracle function LPAD to MSSQL

  1. #1
    Join Date
    Dec 1999
    Location
    Denmark
    Posts
    2,801

    Oracle function LPAD to MSSQL

    Anyone know how to convert the (Oracle8) function LPAD (left-padding a field with specific characters) to MS SQL (7.0)?

    MSN says "N/A" to LPAD/RPAD when comparing functions.


    ------------------
    Karl, Denmark
    ---------
    "..and may The Force be with you - too..."

    [This message has been edited by kallikru (edited 08-17-2001).]
    Karl, Denmark
    ---------
    "..and may The Force be with you - too..."

  2. #2
    Join Date
    Dec 1999
    Location
    Denmark
    Posts
    2,801
    ^bump^

    ------------------
    Karl, Denmark
    ---------
    "..and may The Force be with you - too..."
    Karl, Denmark
    ---------
    "..and may The Force be with you - too..."

  3. #3
    Join Date
    Nov 2008
    Posts
    1

    here we go......

    using LPAD :
    -----------

    table users
    -----------------|
    |id | name |
    |--------------- |
    | 1 |liwa ganteng |
    ---------------- |

    example oralce : select lpad(id,5,0), name from users
    result : 00001 | liwa ganteng

    example Ms SQL : select replicate(0,5-len(id))+id, name from users
    result : 00001 | liwa ganteng

    using RPAD :
    -----------
    example oralce : select rpad(id,5,0), name from users
    result : 10000 | liwa ganteng

    example Ms SQL : select id+replicate(0,5-len(id)), name from users
    result : 10000 | liwa ganteng

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •