Insert for a table

5 pts.
Tags:
INSERT statement
I have a table which consists of lakhs of records and itemnumber is one of the column.I want to insert those records into the same table but with different new itemnumber from another table.what is the best way of doing it?
ASKED: August 6, 2008  5:03 AM
UPDATED: August 6, 2008  7:59 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Does the other table have the new item numbers?

If so you can simply use an insert statement to copy the data.

<pre>INSERT INTO ItemTable
(ItemId, ItemName)
SELECT ItemId, ItemName
FROM OtherTable</pre>

Is the ItemId column an IDENTITY Column?

If so it will assign new numbers for you automatically.

<pre>INSERT INTO ItemTable
(ItemName)
SELECT ItemName
FROM OtherTable</pre>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following