SQL INSERT ALL

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)
 
D

Douglas J. Steele

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"
 
D

DS

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
 
D

Douglas J. Steele

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>
 
D

DS

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
 
Top