Solved

Insert data into multiple tables.

Posted on 2002-05-07
5
177 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

863 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

25 Experts available now in Live!

Get 1:1 Help Now