Solved

Changing a column to "Is Identity = Yes" when data exists in the column.

Posted on 2013-12-11
2
242 Views
Last Modified: 2013-12-11
Hello Experts,

I have imported data from Excel into MS SQL Server 2012 Express. All of the records have IDs already assigned to them. My task was and is to take the Excel data and normalize it into various tables and basically build a database. I went about this by breaking out the data into Excel sheets and manually assigning IDs to related the data together. Now that I am finished with that process I am ready to import into MS SQL Server, but I see that what I intended to be the Primary Key for each table, I cannot set the Is Identity = Yes attribute. Is that because there is already data in the table? Is there a way to do this? What is your advice for me? I suppose I could just add a new column to each table once imported and make it the Primary Key and set Identity = Yes, but I don't know if that's they best answer.

Thank you,
Riverwalk
0
Comment
Question by:RiverWalk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
Guru Ji earned 500 total points
ID: 39712138
Check your column data type for ID you are importing from excel.

If it is varchar then you can't change it to identity column.

To change it to identity column, it should have int data type.
0
 

Author Comment

by:RiverWalk
ID: 39712351
In Excel, the column is the "number" format, but once it comes into SQL Server it is of data type, "float". I have set the decimal setting to zero in Excel, but it still comes into MS SQL Server as float. However, your comment prompted me to try something that I thought I tried before but was not sure if I really followed through with it. I thought I tried changing the field from float to int in SSMS, but I guess I did not, because I just tried it and it worked, After changing to int and saving it, then I was able to set Is Identify = Yes. Great!

I think I was afraid that changing the data type in SQL Server would drop the table and cause me to lose data. But it didn't.

Thank you!

Riverwalk
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

688 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