Old db table
ID Username
-
15 Peter
45 James
When pasting the same data to teh new db, I would get this:
ID Username
-
1 Peter
2 James
You can see the ID field values become different (since the ID attribute is an identity and the table in the new db is empty, the db picks the values 1 and 2 for the two records) and now when pasting data into related tables, I get the error because table relations (which are based on identities) do not match. How do I solve this problem and import all the data into the new db while maintaining correct relationships among tables?
Issue SET IDENTITY_INSERT <table-name> ON prior to loading the data! that enables you to load whatever values you like into there.
-Jamie
|||It probably works when running INSERT sentences, but I want to copy-paste data using SQL Server Management Studio Express.
Maybe there's a way to export the data into txt format by generate INSERTS?|||
Copying and pasting is not a method of moving data between tables.
Generating inserts is a very good idea. Do a search on the internet for sp_generate_inserts
-Jamie
No comments:
Post a Comment