0

Possible Duplicate:
SQL Server: Is it possible to insert into two tables at the same time?
Select from one table and insert to another two table

I have two tables with one-to-one relationship according to the result of a select statement I need to insert the resultant values in those tables I really need to avoid cursors, do you know how I could insert in both tables with one select statement , or do you know some other solution that is better in performance, the table I'm querying is expected to get really huge and looping through it would be bad

thanks in advance

Community
  • 1
  • 1
Maha Khairy
  • 352
  • 5
  • 15
  • 2
    Please be more specific .What is your table structure ?what are your resultant values and what have you tried till nw ..! – praveen Jul 19 '12 at 10:03
  • one of possible solutions [http://stackoverflow.com/questions/2247679/sql-server-trigger-insert-values-from-new-row-into-another-table] (Sql Server trigger insert values from new row into another table) – vasja Jul 19 '12 at 11:38
  • my structure has a parent table with all common fields, and several children tables with respective fields to each type, – Maha Khairy Jul 19 '12 at 11:43
  • I query several joined tables and insert the common data in the parent and the specific data to this child table,I tried a cursor with select from the joined tables but it behaved weird,and I tried adding values to temp table and then use a cursor but this query will run frequently which discouraged me from using temp tables, then I tried a simple plain cursor that reads from just one table then check for my conditions inside the cursor but it seems so 'Brute-Force' – Maha Khairy Jul 19 '12 at 11:50

0 Answers0