Solved

query to add zeros to a number

Posted on 2012-04-02
5
369 Views
Last Modified: 2012-06-27
I have a list of ID numbers, what I need to do is add zeros to the front of the number for every number that is less than 8 digits.  for example 123456 should be 00123456
0
Comment
Question by:smurfer69
5 Comments
 
LVL 21

Expert Comment

by:JestersGrind
ID: 37797403
Convert it to a string.  Concatenate 7 zeros on to the left of the string.  Trim the string to only use the right 8 characters.

Greg
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37797407
right('00000000' + your_number,8)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37797408
In Your query

Format (yourfield, "00000000")
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
ID: 37797410
You could try Format(fieldNameForIDnumbers,"00000000").  Now this will not update the table itself, it will just show you the ID numbers with 8 digits.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37797411
ha, that's even nicer  :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question