Skip navigation

How can I pad an integer value in SQL Server with zeroes?

A. By converting to a string and padding that way. e.g. an example from pubs to pad a value :-

select right(replicate('0',10)+ convert(varchar(10),ytd_sales),10) from titles


TAGS: SQL
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish