Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 insert to link table

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-02-04 : 11:11:46
Greetings

I am trying to insert into a link table. If this subject has been dealt with can you please "link" me to it.

This is the scenario
I have three tables

WorkOrders
Tickets
WorkOrderTicket

Users are able to see new work orders entered in Mainframe app via application designed. They can now create a ticket for the work order they select.
We need to populate both the WorkOrders table (in the mainframe app the work orders do not have a UniqueID) a new ticket in the ticket table and a link for both records in WorkOrderTicket. We haev a many to many relationship between WorkORders and WorkOrderTicket.
Right now I am doing the inserts and keeping the values of the newly created records in a table variable that is populated from the OUTPUT INSERTED.x method. Is this the proper design approach.
Have I explained it clearly?

Thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-04 : 12:07:33
Although its not fully clear, from what i understand you're basically trying to populate master child tables. In such cases, the common approach is exactly what you're using i.e getting inserted ids using OUTPUT operator and then using it for insertion in child later.
Go to Top of Page
   

- Advertisement -