Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Mar 6, 2000

Entering Information Into Two Tables at Once

Question:
I have two tables:
Items_table: Item_id (primary key)
       Description (foreign key)
       Item_price

Descrip_table: Description (primary key)
       Item_type
How do I enter information into the two Description columns simultaneously?

Answer:
An insert statement can only insert into one table. So there is no way to actually insert into two tables in one statement.

However, if you wrap the two insert statements into a transaction, then both insert statements are treated as one unit of work.

Therefore, either both are successful or none are. And no one will be able to see any of the rows being inserted till they are both committed.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap