SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

rama108
Posting Yak Master

109 Posts

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

USA
37460 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
http://weblogs.sqlteam.com/tarad/

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

James K
Flowing Fount of Yak Knowledge

3760 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

rama108
Posting Yak Master

109 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  
 New 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.06 seconds. Powered By: Snitz Forums 2000