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

Recommended Answers

All 3 Replies

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

First I want to insert topic table. After I want to insert reply table. However I want to use topicId in reply table.

use SP, so you've variable carries topicID

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.