SQL INSERT ALL

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I need to INSERT al of the records from the SecurityHold table into the
SecurityDetails table but my syntax seems to be off. Any help apprreciated.
Thanks
DS

Dim ALLSQL As String
ALLSQL = "INSERT * INTO SecurityDetails " & _
FROM SecurityHold;"
DoCmd.RunSQL (ALLSQL)
 
Assuming that the two tables have exactly the same fields, you can use:

ALLSQL = "INSERT INTO SecurityDetails " & _
"SELECT * FROM SecurityHold"

Realistically, though, I'd recommend:

ALLSQL = "INSERT INTO SecurityDetails " & _
"Field1, Field2, ... " & _
"SELECT Field1, Field2, ... FROM SecurityHold"
 
Douglas said:
Assuming that the two tables have exactly the same fields, you can use:

ALLSQL = "INSERT INTO SecurityDetails " & _
"SELECT * FROM SecurityHold"

Realistically, though, I'd recommend:

ALLSQL = "INSERT INTO SecurityDetails " & _
"Field1, Field2, ... " & _
"SELECT Field1, Field2, ... FROM SecurityHold"
Douglas
They both do have the same fields. Out of curiosity why would you
recommend the 2nd one.
Thanks Douglas
DS
 
DS said:
Douglas
They both do have the same fields. Out of curiosity why would you
recommend the 2nd one.
Thanks Douglas

Just in case you change one table or the other.

In my opinion, you should always be explicit, rather than depending on
Access to figure out what you want. <g>
 
Douglas said:
Just in case you change one table or the other.

In my opinion, you should always be explicit, rather than depending on
Access to figure out what you want. <g>
Your Right about that!
Thanks
DS
 

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

Similar Threads

SQL Other Database 2
Is This Right? 3
SQL Statements 2
SQL SYNTAX ERROR 8
SQL "insert into" syntax 4
DoCmd.RunSQL - Need help! 1
SELECT INSERT 1
Select From 1

Back
Top