Solved

importing data to sql 2008, identity column

Posted on 2011-09-10
4
307 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
  • 3
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Many Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

10 Experts available now in Live!

Get 1:1 Help Now