Import of data into SQL Server table with an identity column

i am in the process of exporting data from a Pervasive database to an SQL Server 2008 database.

In one table there is an identity column. I need to keep the same identity value in the new table in SQL Server when i do the import.

What do i need to do?

Since SQL Servers import wizard does not support Pervasive (very well) i will be writing a program that reads from the Pervasive database and inserts into the SQL Server database.
soozhAsked:
Who is Participating?
 
Asim NazirCommented:
Before importing data into target table. Remove AutoIncrement property of it. Once data is imported you can set it again. If you need further help let me know.

Asim
0
 
soozhAuthor Commented:
i am not an sql expert... what is the tsql statement to do this?
0
 
Asim NazirCommented:
You can set following in your query:
SET IDENTITY_INSERT dbo.tb_ErrorLog ON
0
 
cheers4beersCommented:
Why not use the import/export wizard, and use the "enable Identity Insert" option?  With SQL 2005, there was an issue with the having the wizard create the tables in the destination database, and it would not include any constraints/keys.

First, generate a script to create the table(s)

Then, use the wizard to import the data, and enable identity inserts.
0
 
Asim NazirCommented:
Please see:

SET IDENTITY_INSERT (Transact-SQL)
http://msdn.microsoft.com/en-us/library/ms188059.aspx 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.