Solved

Insert data into multiple tables.

Posted on 2002-05-07
5
176 Views
Last Modified: 2010-05-02
can I use the SQL command to insert data into two tables together.  i have two tables A and B. I would live to insert data into field of both tables.  I have recorsets for each table inritistic(basic) data control, but dont know how to insert using data control properties.  I can insert into one table tough.
0
Comment
Question by:panesar
5 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 6995077
If you have two different recordsets, one for each, you can update the fields in the recordset

rs1.field("name").value = "First"
rs1.update

rs2.field("name2").value = "Last"
rs2.update

You can also create two different INSERT or UPDATE statements, one for each table.

INSERT INTO table1 (name) values('First')
INSERT INTO table2 (name2) values('Last')

UPDATE table1 SET name = 'First'
UPDATE table2 SET name2 = 'Last'

Hope this helps


0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6995406
you can only INSERT into a singel table at a time.  It is not possible, with ONE insert statement. to insert data into two or more tables in the same SQL Statement.
0
 
LVL 3

Accepted Solution

by:
shyamkumarreddy earned 50 total points
ID: 6996177
Yeah You can do it Panesar
YOu have have to create a View of the 2 different tables into one view.
And with a single SQL statement you can insert into 2 different tables.

Shyam
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7722372
Hi panesar,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept shyamkumarreddy's comment(s) as an answer.

panesar, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7780138
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now