Solved

importing data to sql 2008, identity column

Posted on 2011-09-10
4
368 Views
Last Modified: 2012-05-12
I have a set of non related tables in sql server.

Product Table
columns: productID, product bar code, description
it is populated with values:
1        wewe444           box
300   wewe889            pen
301   weweppo            pencil
(productId's are unique in this table)

I have created a relational database with the same columns for product table. I set productID to primarykey and identity column.

am I going to have problem when I import data to this new table?..how productID's are going to be imported to the identity column?

thanks in advance
0
Comment
Question by:shmz
[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
  • 3
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 36516247
to insert rows into a table with identity field, giving a value for that field instead of letting the identity assign one automatically, you need to use this:
http://msdn.microsoft.com/en-us/library/aa259221%28v=sql.80%29.aspx
0
 

Author Comment

by:shmz
ID: 36516305
Hi Angelll,

Thanks for the article. This means when I do a bulk import for the first time into an empty destination table, it should not cause any problem, given that the source table has unique productIds. Right?

Also after bulk import is done, when I start to add individual new items to destination table, the database automatically recognizes what the new productID is, regardless of what stored in the last row of the table (as it may not be in correct order)?

Thanks
0
 

Author Comment

by:shmz
ID: 36516476
Angelll, Thanks for the information. I just tested the database, and the sql does find what is the highest identity value in the column and then set the new record accordingly.

Thanks
0
 

Author Closing Comment

by:shmz
ID: 36516478
Many Thanks
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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