Solved

MS Sql Convert int column to identity conserving data

Posted on 2010-08-31
1
405 Views
Last Modified: 2012-05-10
I have a field with integers, they are not repeated and go from 1 to 1000, I need it to set it as an identity column (1,1) preserving the data it has since it is the key for a relation with another table.

This table was imported from a system that incremented this field by 1 manually.


0
Comment
Question by:robrodp
1 Comment
 
LVL 1

Accepted Solution

by:
zapacila89 earned 500 total points
ID: 33572860
If you have access to enterprise manager or SSMS, you can browse to the table, right click => design.

In the definition of the table, select the column, set identity on and seed value to the last existing value in the table. Do save.

More info on the steps

Highlight the column (actually a row in this presentation) you are interested in by left clicking the gray square to the left of the column name.
With the row highlighted the column detail will be shown in the bottom half of the window with all the things you need.

Next record inserted into to the table will have the next identity column auto incremented.

(In SSMS 2005 you simple change the column to be as identity same from the design window (rigt-clik on table name an click design) and clicking on the column in the bottom will appear a table of properties which contains Identity specification. In SSMS 2005 it will automatically pick from the next number)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now