Solved

SQL 2005 Export Data

Posted on 2006-11-06
7
1,279 Views
Last Modified: 2007-12-19
Hi Experts,

I have a problem where I'm trying to export data from a SQL 2000 box to my new SQL 2005 box. I've scripted all the tables / views / stored procedures / full text catalogues etc, no problems. When Exporting the data, it all transfers across fine but the uniqie ID's are changed. An example would be:

SQL 2000 DB
Table: tblUsers
UserID: 4
Username: Joe
Password: letmein
-----------------------------------------
SQL 2005 DB
Table: tblUsers
UserID: 1
Username: Joe
Password: letmein

As you can see, the UserID has changed for this user which doesn't help as you can imagine :/ This goes for all my tables. I've tried the "Database Copy" wizard but that doesn't work at all. I prefer to use the Data Export / Import anyway. Also, I don't have "Enable Identity Insert" enabled when transfering the tables.

Ta.
0
Comment
Question by:blandyuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17881285
>>Also, I don't have "Enable Identity Insert" enabled when transfering the tables.<<
You will need to enabe this check box and include the Identity column in the transform.
0
 
LVL 9

Author Comment

by:blandyuk
ID: 17881440
I don't know what you mean by:
"and include the Identity column in the transform"

?? I include all columns in the transform. I've tried it with "Enable Identity Insert" with no luck :(
0
 
LVL 9

Author Comment

by:blandyuk
ID: 17881849
I found this article which is exactly the problem I'm having but I'm still having trouble as to what exactly I'm surposed to do:

------------------

>Question:<
I have a question regarding export / import when you have tables with  autonumber (identity) columns as primary surrogate keys. Does export / import retiain the values of these columns so that referential integriy is not broken?

>Answer:<
Yes!
Depending on how you import the data, make sure you choose the correct option that you wish to explicitely insert your "own values" into an IDENTITY column.
You might want to check BOL for SET IDENTITY_INSERT or BULK INSERT...KEEPIDENTITY or BCP -E. There is also some equivalent when you use DTS, but since I don't use DTS, I don't know what option to check there.

>Reference:<
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=78716&SiteID=1
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 11

Accepted Solution

by:
regbes earned 250 total points
ID: 17881942
Hi blandyuk,

restoring a 2000 backup into the 2005 db is the easyest way to do this ( remember to change the compat level to 90 when done )

blandyuk,
> I don't know what you mean by:
> "and include the Identity column in the transform"

this means when it is not enabled new id's will be generated resulting in the behaviour you saw when it is enabled you (or the import process ) can assign the id a value from the exsisting data

HTH

R.


0
 
LVL 9

Author Comment

by:blandyuk
ID: 17882111
Found another article:

>Article:<
Enable identity insert is ignored when "optimize for multiple tables" is enabled. Unfortunately that option ensures that the import operation observes referential integrity between foreign key connected tables according to this blog: http://blogs.msdn.com/chrissk/archive/2006/06/24/645968.aspx.

Very, very, annoying.

>Reference:<
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=135905

Yeah, I'll have to restore it from a backup when I do it. I've already done this and I know it works. I've tried copying data without the "optimize for multiple tables" and it totally fails.

Ah well!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17883019
Sorry, I misunderstood the quesiton, I thought you were using DTS, I see now that it is SSIS that you are using.
0
 
LVL 9

Author Comment

by:blandyuk
ID: 17971134
Thanks regbes, I've just been creating a backup and restoring that now. I would have thought SQL 2005 Management Studio would have made is easy to transfer a database :/ It's easy in Enterprise Manager.

Doesn't matter anyway, sorted now.

Blandy
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question