Copy data from on table to another ?

S

SpookiePower

I have lost a lot of data in my backend, but
it is only data from a few columns, in one tabel, that I have lost.

My tabel is called taCustemor, and the columns in that
table is called fakFirm, fakAdress. I have use a custemornumber
as a primarykey.

So now I want to copy only these columns from my backup
of the backend to my backend in use.
I'm sure that I can do this buy using SQL, but I'm
not sure how to make this querie.

Can some one out there help me ?
 
K

Ken Snell \(MVP\)

You want to use an append query. See Help file for info.

In the database where you want the data to be when you're done, create a
link to the appropriate table(s) in the backup copy of the database. Then
create an append query to copy data from the linked table(s) to the table(s)
in the current database file.
 
J

John Spencer

Ken,

Pardon me, but I think the poster needs to use an UPDATE query since they
have lost data from SOME columns and not lost records.

Otherwise, I think your advice is good.

Assuming that the poster links to the backup copy and his linked table is
named taCustemor when the poster creates the link to the backup he/she will
get a new table named taCustemor_1.

Assumption:
The blank fields are null and do not contain a zero-length string.
You want to do the replacement with only one query

The SQL for that would look something like the following.

UPDATE taCustemor INNER JOIN taCustemor_1
ON taCustemor.custemornumber = taCustemor_1.custemornumber
SET taCustemor.FakFirm = IIF([taCustemor].[FakFirm] Is
Null,[taCustemor_1].[FakFirm], [taCustemor].[FakFirm]),
taCustemor.fakAdress=IIF([taCustemor].[fakAdress] Is
Null,[taCustemor_1].[fakAdress],[taCustemor].[fakAdress])
WHERE taCustemor.fakAdress Is Null Or taCustemor.fakFirm is Null




--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
K

Ken Snell \(MVP\)

I think you're right!
< g >

--

Ken Snell
<MS ACCESS MVP>

John Spencer said:
Ken,

Pardon me, but I think the poster needs to use an UPDATE query since they
have lost data from SOME columns and not lost records.

Otherwise, I think your advice is good.

Assuming that the poster links to the backup copy and his linked table is
named taCustemor when the poster creates the link to the backup he/she
will get a new table named taCustemor_1.

Assumption:
The blank fields are null and do not contain a zero-length string.
You want to do the replacement with only one query

The SQL for that would look something like the following.

UPDATE taCustemor INNER JOIN taCustemor_1
ON taCustemor.custemornumber = taCustemor_1.custemornumber
SET taCustemor.FakFirm = IIF([taCustemor].[FakFirm] Is
Null,[taCustemor_1].[FakFirm], [taCustemor].[FakFirm]),
taCustemor.fakAdress=IIF([taCustemor].[fakAdress] Is
Null,[taCustemor_1].[fakAdress],[taCustemor].[fakAdress])
WHERE taCustemor.fakAdress Is Null Or taCustemor.fakFirm is Null




--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

Ken Snell (MVP) said:
You want to use an append query. See Help file for info.

In the database where you want the data to be when you're done, create a
link to the appropriate table(s) in the backup copy of the database. Then
create an append query to copy data from the linked table(s) to the
table(s) in the current database file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top