Solved

MS Sql Convert int column to identity conserving data

Posted on 2010-08-31
1
404 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

22 Experts available now in Live!

Get 1:1 Help Now