User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 423,510 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,700 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1550 | Replies: 3
Reply
Join Date: Sep 2007
Posts: 4
Reputation: Turing is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Turing Turing is offline Offline
Newbie Poster

insert to multiple table

  #1  
Oct 14th, 2007
I want to insert 2 table at the same time . There are relationship between them .My tables are:

Topic : topicId, topicDate,topicInformation
Reply: replyId,topicId, replyInformation
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: insert to multiple table

  #2  
Oct 14th, 2007
Create proc InsertIntoMyTables
@topicID int,
...
...
AS
Insert into Topic values (@topicID,....)
Insert into Reply values(@replyID,....)

or you can use 2 insert statements but DON'T sepeate them with GO

or you can use Insert with inner join I don't remember it right now, if I do I'd reply again
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Sep 2007
Posts: 4
Reputation: Turing is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Turing Turing is offline Offline
Newbie Poster

Re: insert to multiple table

  #3  
Oct 14th, 2007
First I want to insert topic table. After I want to insert reply table. However I want to use topicId in reply table.
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: insert to multiple table

  #4  
Oct 14th, 2007
use SP, so you've variable carries topicID
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 4:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC