How do I pad an Integer to 4 digits with leading zeros?

June 6, 2008 at 11:36 pm Leave a comment

Run the following SQL code:

SELECT RIGHT(‘0000’ + YourValue), 4)

Note: To pad to a different number of digits, replace the ‘0000’ and the 4 as appropriate, eg. SELECT RIGHT(‘00000000’ + YourValue), 8) will pad to 8 digits.

Advertisements

Entry filed under: SQL Scripts. Tags: , , , , , , .

How do I check the Default Server Collation (case-sensitivity) of a SQL Server installation? How do I list all tables WITHOUT a primary key?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

June 2008
M T W T F S S
    Jul »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Archives

Blog Stats

  • 32,523 hits

%d bloggers like this: