Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update ID 1

Status
Not open for further replies.
Aug 24, 2005
56
US
Is there a way to update a 7 digit ID (7000210) to a 10 digit ID by adding preceding 0's to the number. So the new ID would be 0007000210.

Thanks,

Kevin
 
not if you are storing it as a number. If you want to store the extra zeros you will need to change it to a text field. You could also just modify the format of the number to display the correct number of characters using the FORMAT command.


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
Hi Leslie... The ID is stored as text not a number. What do I do in that case?
 
something like this should work:

update TableName SET FieldName = "000" + FieldName

I would test it first by using a query like:

SELECT FieldName, "000"+FieldName As NewField From TableName

if you get the results you are expecting, then run the update query.



Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top