How to increment by one in SQL table

Hi all.

I have a table (tblRef) that has a column: Ref_No which is a 4 digit number (first one is 1000) as well as other data, I would to be able to make Ref_No 5 digits instead of 4, is there a way to run an update query that will make all of the values in the Ref_No column increment to 5 digits?

 Currently, the field is data type: int, what do I have to change it to so I can insert 5 digits instead of 4.

For example,

Currently Ref_No has the following data:

1000
1001
1002
1003
1004
1005

I would like them to be changed to:
10000
10001
10002
10003
10004
10005

etc...

Any ideas? Thanks you in advance!
printmediaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joachim CarreinSr. Software DeveloperCommented:
Hello printmedia,



Regards,

joachimcarrein
0
Joachim CarreinSr. Software DeveloperCommented:
sorry, my text went missing

try something like

update myTable update key=key - 1000 + 10000
0
Joachim CarreinSr. Software DeveloperCommented:
ok, something is wrong with me today :s

this should be set instead of second update
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
so you just want to add 9000 to the actual values?:
UPDATE yourtable SET Ref_No = Ref_No + 9000

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
printmediaAuthor Commented:
That's pretty much it, but what should I change the Data Type to, it is currently int.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>but what should I change the Data Type to, it is currently int.
no need to change, int supports values much larger...
0
UnifiedISCommented:
int is big enough
0
Joachim CarreinSr. Software DeveloperCommented:
The range for an int is from -2^31 to 2^31-1, that is 32-bit signed.
so from -2,147,483,648 to 2,147,483,647
0
printmediaAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.