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
Solved

importing data to sql 2008, identity column

Posted on 2011-09-10
4
336 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 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query Syntax 17 43
Present Absent from working date rage 11 36
TSQL recursive CTE challenge... 8 29
Amazon RDS migrate to SQL Server 3 24
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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