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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 Identity Specification
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

115 Posts

Posted - 09/23/2013 :  15:48:28  Show Profile  Reply with Quote
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?


Almighty SQL Goddess

38200 Posts

Posted - 09/23/2013 :  16:04:03  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

Edited by - tkizer on 09/23/2013 16:34:50
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 09/23/2013 :  16:28:24  Show Profile  Reply with Quote
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

Posting Yak Master

115 Posts

Posted - 09/23/2013 :  16:31:47  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000