• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

Add digit to a number

I have a field with an 18 digit number.  I need to add a 0 in the 9th digit making it a 19 digit number.

Example:
111111111111111111
becomes
1111111101111111111

Is there an easy way to do this with a SQL update query?
0
parkcityit
Asked:
parkcityit
  • 3
1 Solution
 
dmitryz6Commented:
left([Yourfield],8) & "0" & mid([Yourfield],9)
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
MyNewNumber = left(CStr(MyOldNumber, 8)) & "0" & right(CStr(MyOldNumber, 10))

Is this value stored in a table.column that is Text or numeric?
0
 
dmitryz6Commented:
UPDATE tblName SET Yourfield = left([Yourfield],8) & "0" & mid([Yourfield],9)
0
 
parkcityitAuthor Commented:
That was ridiculously fast.
0
 
dmitryz6Commented:
You welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now