473,473 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Moving data to SQL Server

Access 2k -> SQL Server 2k

My client has an app that is A2k FE with A2k BE. They have asked me
to move the BE to SQL Server.

I have a bit of experience with SQL Server, and I'm happy with
scripting the database etc.

However, when it comes time to move the data itself, I have a teensy
little concern.

Let's take our typical Customers -> Orders relation, where CustomerID
is the Foreign Key in the Orders table.

Let's say I have 4 customers, but I used to have 6. The CustomerID is
an AutoNum column, and they are 1, 2, 4, 6. However, when I insert
these records into the matching SQL Server table with an Identity
column, they will (presumably) be 1, 2, 3, 4.

So what can I do about the matching orders? Is there any alternative
to this, which seeems very long winded.

1. Insert the records as above, but copy the OLD Access AutoNum
column (called OldCustomerID) into a temporary column in the new SQL
Server table for both the Customers and Orders tables.

2. Insert the Orders records into the new SQL Server table.

3. Run an update query thus:

UPDATE O
SET CustomerID = C.CustomerID
FROM Orders O
INNER JOIN Customers C ON O.OldCustomerID = C.OldCustomerID

Can I do this any easier? For example, is there any way in SQL Server
to maintain the values of the AutoNum field in the Insert but have
them still be Identity fields? I know that I can import the AutoNum
data into a simple int column, and once the import is complete, turn
ON the identity, but is this reliable? Might I lose any data
integrity?

TIA

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk
Jul 20 '05 #1
4 6072
<< I know that I can import the AutoNum
data into a simple int column, and once the import is complete, turn
ON the identity>>

That's the recommended solution.

1) Use the Access upsize wizard to transfer the structure ONLY

2) Change the SQL db's IDENTITY fields (AutoNumber in Access) to int fields.

3) Using DTS, transfer the contents of the Parent and lookup-type tables (do
not include any child tables)

4) Transfer the child tables in the appropriate Foreign key order.

5) when all of the data has been transferred, set int fields back to IDENTITY.

EX: In the Customer>Order>Detail<Product relation, I'd transfer the Customer
and Product tables in step 3, then Order, then Detail.

NOTE: Depending on the number of tables, it might benifit you to REMOVE any
Foreign Key constraints, import ALL of the data at once (basically, we'd be
treating the tables as non-related entities), and then put the FKs back in
there afterward.
Jul 20 '05 #2
DFS
Edward,

You have to turn identity insert on and off when adding values to a SQL
Server identity field.

SET IDENTITY_INSERT TableName ON;
.... issue your inserts
SET IDENTITY_INSERT TableName OFF;

This will maintain your existing Access AutoNumber IDs.

"Edward" <te********@hotmail.com> wrote in message
news:25**************************@posting.google.c om...
Access 2k -> SQL Server 2k

My client has an app that is A2k FE with A2k BE. They have asked me
to move the BE to SQL Server.

I have a bit of experience with SQL Server, and I'm happy with
scripting the database etc.

However, when it comes time to move the data itself, I have a teensy
little concern.

Let's take our typical Customers -> Orders relation, where CustomerID
is the Foreign Key in the Orders table.

Let's say I have 4 customers, but I used to have 6. The CustomerID is
an AutoNum column, and they are 1, 2, 4, 6. However, when I insert
these records into the matching SQL Server table with an Identity
column, they will (presumably) be 1, 2, 3, 4.

So what can I do about the matching orders? Is there any alternative
to this, which seeems very long winded.

1. Insert the records as above, but copy the OLD Access AutoNum
column (called OldCustomerID) into a temporary column in the new SQL
Server table for both the Customers and Orders tables.

2. Insert the Orders records into the new SQL Server table.

3. Run an update query thus:

UPDATE O
SET CustomerID = C.CustomerID
FROM Orders O
INNER JOIN Customers C ON O.OldCustomerID = C.OldCustomerID

Can I do this any easier? For example, is there any way in SQL Server
to maintain the values of the AutoNum field in the Insert but have
them still be Identity fields? I know that I can import the AutoNum
data into a simple int column, and once the import is complete, turn
ON the identity, but is this reliable? Might I lose any data
integrity?

TIA

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk

Jul 20 '05 #3
DFS
Forgot to say something, which I'm sure you know: even with IDENTITY_INSERT,
you still have to populate your tables in the correct order so as not to
violate referential integrity. Parent table first, then child, etc.
"DFS" <no****@nospam.com> wrote in message
news:vu************@corp.supernews.com...
Edward,

You have to turn identity insert on and off when adding values to a SQL
Server identity field.

SET IDENTITY_INSERT TableName ON;
... issue your inserts
SET IDENTITY_INSERT TableName OFF;

This will maintain your existing Access AutoNumber IDs.

"Edward" <te********@hotmail.com> wrote in message
news:25**************************@posting.google.c om...
Access 2k -> SQL Server 2k

My client has an app that is A2k FE with A2k BE. They have asked me
to move the BE to SQL Server.

I have a bit of experience with SQL Server, and I'm happy with
scripting the database etc.

However, when it comes time to move the data itself, I have a teensy
little concern.

Let's take our typical Customers -> Orders relation, where CustomerID
is the Foreign Key in the Orders table.

Let's say I have 4 customers, but I used to have 6. The CustomerID is
an AutoNum column, and they are 1, 2, 4, 6. However, when I insert
these records into the matching SQL Server table with an Identity
column, they will (presumably) be 1, 2, 3, 4.

So what can I do about the matching orders? Is there any alternative
to this, which seeems very long winded.

1. Insert the records as above, but copy the OLD Access AutoNum
column (called OldCustomerID) into a temporary column in the new SQL
Server table for both the Customers and Orders tables.

2. Insert the Orders records into the new SQL Server table.

3. Run an update query thus:

UPDATE O
SET CustomerID = C.CustomerID
FROM Orders O
INNER JOIN Customers C ON O.OldCustomerID = C.OldCustomerID

Can I do this any easier? For example, is there any way in SQL Server
to maintain the values of the AutoNum field in the Insert but have
them still be Identity fields? I know that I can import the AutoNum
data into a simple int column, and once the import is complete, turn
ON the identity, but is this reliable? Might I lose any data
integrity?

TIA

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk


Jul 20 '05 #4
Unfortunately there is a bug in MSSQL 2000 so that 'set identity_insert on'
does not work as expected.

My company managed to get a hotfix from Microsoft, so see if you can get it
too or use the other method from the article before

Regards, Robert

--

"DFS" <no****@nospam.com> schrieb im Newsbeitrag
news:vu************@corp.supernews.com...
Edward,

You have to turn identity insert on and off when adding values to a SQL
Server identity field.

SET IDENTITY_INSERT TableName ON;
... issue your inserts
SET IDENTITY_INSERT TableName OFF;

This will maintain your existing Access AutoNumber IDs.

"Edward" <te********@hotmail.com> wrote in message
news:25**************************@posting.google.c om...
Access 2k -> SQL Server 2k

My client has an app that is A2k FE with A2k BE. They have asked me
to move the BE to SQL Server.

I have a bit of experience with SQL Server, and I'm happy with
scripting the database etc.

However, when it comes time to move the data itself, I have a teensy
little concern.

Let's take our typical Customers -> Orders relation, where CustomerID
is the Foreign Key in the Orders table.

Let's say I have 4 customers, but I used to have 6. The CustomerID is
an AutoNum column, and they are 1, 2, 4, 6. However, when I insert
these records into the matching SQL Server table with an Identity
column, they will (presumably) be 1, 2, 3, 4.

So what can I do about the matching orders? Is there any alternative
to this, which seeems very long winded.

1. Insert the records as above, but copy the OLD Access AutoNum
column (called OldCustomerID) into a temporary column in the new SQL
Server table for both the Customers and Orders tables.

2. Insert the Orders records into the new SQL Server table.

3. Run an update query thus:

UPDATE O
SET CustomerID = C.CustomerID
FROM Orders O
INNER JOIN Customers C ON O.OldCustomerID = C.OldCustomerID

Can I do this any easier? For example, is there any way in SQL Server
to maintain the values of the AutoNum field in the Insert but have
them still be Identity fields? I know that I can import the AutoNum
data into a simple int column, and once the import is complete, turn
ON the identity, but is this reliable? Might I lose any data
integrity?

TIA

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk


Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Stephen Ghelerter | last post by:
I am moving a web site with a MySql database to another server. Can I create a database on the new server with the same name and then move the tables there, or is life not that simple? Or can I...
6
by: davidmdalle | last post by:
Hello, I have been having a bit of trouble finding help on the safest way to move data files to a different disk on the same server. Most help is about moving data files to a different sqlserver. ...
1
by: Mr. x | last post by:
.... The second time I am sending this email ... .... I want a good solution, please. .... Thanks :) What I need is moving xml data from client to server & vice versa, but not using xml file....
4
by: Ron Mexico | last post by:
Hi, Currently have an app that maintain that is written in VB6 and uses an access db (backend db only used as a data store not writing to the db). This app is a client app not server multi-teir...
6
by: Woody Splawn | last post by:
I have been using SQL Server 2000 on my stand-alone machine as a back-end to a VS.net application. It is time to switch environments and take the application to the customer. I need to install...
2
by: fuzzybr80 | last post by:
I am using MySQL 5.0 with a number of innodb tables whose ibdata files are growing quite quickly and filling up the /var partition (file is /var/mysql/ibdata1). Earlier on I followed instructions...
3
by: UJ | last post by:
I've got a working web service that we are moving to another machine and now I suddenly get the following error. While transferring the files, got the following message:...
7
by: =?Utf-8?B?TW9iaWxlTWFu?= | last post by:
Hello everyone: I am looking for everyone's thoughts on moving large amounts (actually, not very large, but large enough that I'm throwing exceptions using the default configurations). We're...
14
by: rabbitrun | last post by:
Hi Everyone, I work for a financial company. I am planning to give a presentation to rest of the development team (15 people) here on moving server side logic to client-side javascript for an...
0
by: Nishanthmarathe | last post by:
Hi There!!! I am new to C# world. I am getting huge chunk of data from a 3rd party applications thru SOAP request and updating to my SQL Server. I cant implement Progress bar as there is no way...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.