-1

I there a way to pad String result in SQL server?

Select str from table_name where...

I want str to return with length of 13 with leading '0'.

For example:

  1. if str = '12345678910' my where will return 13 positions: '0012345678910'

  2. str = '12345' -> '000000012345'

In addition, after padding the result i need to query str 3,4 position.

Is there a way to do all of this in one query?

Michael A
  • 5,770
  • 16
  • 75
  • 127

1 Answers1

0

Try using (T-SQL):

SELECT RIGHT(REPLICATE('0',13)+ '12345',13)

Or (Oracle) :

http://www.techonthenet.com/oracle/functions/lpad.php

cubitouch
  • 1,929
  • 15
  • 28