Solved

SQL 2005 Export Data

Posted on 2006-11-06
7
1,269 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
  • 4
  • 2
7 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
>>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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 11

Accepted Solution

by:
regbes earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now