Solved

SQL -Import records into table with auto ID field

Posted on 2010-08-23
5
441 Views
Last Modified: 2012-05-10
I have a list of emails that I want to import into an table that already has records  with a auto ID field.  I just want the auto ID field to assign a number just like it does when one email is added through the form.  What syntax to I add to the SQL INSERT INTO statement to do that without messing up the data in the table.  The fields are ID, email and date and the table can be called table.

Any help is appreciated,
Thanks
0
Comment
Question by:JohnMac328
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
valkyrie_nc earned 500 total points
ID: 33501410
When you get ready to import the data, run this for the table:

SET IDENTITY INSERT [TableName] ON
GO

When you're done and ready for the identity to start again,

SET IDENTITY INSERT [TableName] OFF
GO

hth

valkyrie_nc
0
 

Author Closing Comment

by:JohnMac328
ID: 33501460
Thanks
0
 

Author Comment

by:JohnMac328
ID: 33501583
Is it possible to set that value in the table manually?  I tried running the statement in a query and I got an error.
0
 
LVL 9

Expert Comment

by:valkyrie_nc
ID: 33502615
You can only do it prior to an INSERT statement of some kind (whether T-SQL or SSIS or whatever doesn't matter AFAIK).

Post your code and error message and I'll see if I can help.
0
 

Author Comment

by:JohnMac328
ID: 33502623
No problem, I got it.

Thanks for writing back.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can Unique column have more than one Null? 8 48
How to count in a table in php 22 19
category table 2 8
MySQL Error Code 2 6
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

23 Experts available now in Live!

Get 1:1 Help Now