Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 Identity Specification

Author  Topic 

rama108
Posting Yak Master

115 Posts

Posted - 2013-09-23 : 15:48:28
Hello,
I imported data from a database that has tables with identity columns. After the import, the destination database is missing the identity specification on the columns. How do I resolve it?

Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-09-23 : 16:04:03
You can use SSMS to add the identity and then check the SQL it'll use. It'll create a new table with the proper schema, migrate the data over to the new table, drop the old table and then rename the new table to the old table's name. It's a lot of coding, so let SSMS take care of it for you. You just need to change the option in the column's property.

Also, this is one of the reasons I never recommend using the import/export wizard. I always use backup/restore or detach/attach methods to copy a database. You'll never have an issue like this with those methods as you are guaranteed an exact copy.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-23 : 16:28:24
Another alternative is to pre-create the tables in the new database (using scripts generated from the original database), and then use SSIS to import the data. Be sure to check "Allow Identity Insert" when you use import/export wizard. It is in one of the screens in Import/Export wizard

Of course, going through all that effort makes sense only if you want to import just one or two tables from your source database to a new database. If you are trying to port everything from the old database to the new database, I concur with Tara's advice of backup/restore.
Go to Top of Page

rama108
Posting Yak Master

115 Posts

Posted - 2013-09-23 : 16:31:47
Thank you guys, I appreciate your time. I created the tables from generated scripts and then ran the insert scripts.
Go to Top of Page
   

- Advertisement -