By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Select primary key with import spec?

P: n/a
Have been using macros to do automatic importing of flat text files
lately....wish I knew about his capability before :)

question: is there any way to specify one of the fields I import as
being the primary key? need to do this automatically, not manually.

the spec i create does have the ability to create an index, and one
with no duplicates....but can it make a field this field the primary
key as well?

thanks,

Larry
- - - - - - - - - - - - - - - - - -
"Forget it, Jake. It's Chinatown."
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 01 Sep 2004 19:25:35 -0700, Larry Rekow <larry@netgeexdotcom>
wrote:

There are severe limitations to what you can do with macros. This is
one of them.
To paraphrase yourself: one day you'll discover VBA and its power, and
you'd wish...

-Tom.
Have been using macros to do automatic importing of flat text files
lately....wish I knew about his capability before :)

question: is there any way to specify one of the fields I import as
being the primary key? need to do this automatically, not manually.

the spec i create does have the ability to create an index, and one
with no duplicates....but can it make a field this field the primary
key as well?

thanks,

Larry
- - - - - - - - - - - - - - - - - -
"Forget it, Jake. It's Chinatown."


Nov 13 '05 #2

P: n/a
On Wed, 01 Sep 2004 22:11:45 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Wed, 01 Sep 2004 19:25:35 -0700, Larry Rekow <larry@netgeexdotcom>
wrote:

There are severe limitations to what you can do with macros. This is
one of them.
To paraphrase yourself: one day you'll discover VBA and its power, and
you'd wish...

-Tom.

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
Won half the war. i destroy and make new tables each night after a
text report comes out of a UNIX box. Now I run a macro from access
that deletes the old table, copies an empty table (with the primary
key prefigured) to the table name I want. Then I do the transfer text
thing, importing the text report to a holding table. then run an
append query that appends the records to the new, empty table that
already has the primary key chosen on it. Not elegant, but workable.

but now my biggest problem: I can't seem to import this table from
Access to SQL and preserve the primary key. Googled all over, and
have had conflicting stories....some say you can't, others say you
can. Certainly if I could do it all using SQL DTS, I would, but I
can't figure out how yet.

Certainly if I did it manually, i guess I could do the Access upsize
wizard....that's supposed to keep the primary key..but it's not
automated.

so now i guess i'll have to find out how to use either VBA or VB.net
to see if i can make some sense of it all.

sheesh.

Larry

- - - - - - - - - - - - - - - - - -
"Forget it, Jake. It's Chinatown."
Nov 13 '05 #3

P: n/a
On Thu, 02 Sep 2004 09:22:51 GMT, Chuck Grimsby
<c.*******@worldnet.att.net.invalid> wrote:
On Wed, 01 Sep 2004 19:25:35 -0700, Larry Rekow <larry@netgeexdotcom>
wrote:
Have been using macros to do automatic importing of flat text files
lately....wish I knew about his capability before :)
question: is there any way to specify one of the fields I import as
being the primary key? need to do this automatically, not manually.
the spec i create does have the ability to create an index, and one
with no duplicates....but can it make a field this field the primary
key as well?


Never, never, never import into a new table. Import into an existing
table that has all the keys needed already set up. Use a delete query
to empty the table when/as needed.

Never *delete* a table if you are just going to re-create it. See
previous discussions on this for more information as to why that's a
bad practice.

++++++++++++++++++++++++++++++++++++++++++++++++++ ++
Makes total sense...thanks for the input. Now I just need to find out
how to do the same thing in a MS SQL 2000 db (empty or delete all
records in a table with defined primary key, and then append new
records to the table).

Larry
- - - - - - - - - - - - - - - - - -
"Forget it, Jake. It's Chinatown."
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.