Solved

SQL 2005 Export Data

Posted on 2006-11-06
7
1,275 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
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

816 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

10 Experts available now in Live!

Get 1:1 Help Now