Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Insert data into multiple tables.

Posted on 2002-05-07
5
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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