Inserting records from one table into many tables

  • Can someone post the basic syntax for inserting data from 1 table into multiple tables? Here's what I have so far just to give you an idea so far.

    INSERT INTO

    [interval.dbo.datetime], [location.dbo.pop], [location.dbo.ipaddress], [params.dbo.valid], [params.dbo.service], [params.dbo.host],

    [params.dbo.target], [params.dbo.transid], [stats.dbo.avail], [stats.dbo.value1], [stats.dbo.value2], [stats.dbo.resp], [stats.dbo.size], [stats.dbo.tput]

    SELECT datetime, customer, ipaddr, valid, probename, host, target, transid, availability, metric_1, metric_2, metric_5, transfertput

    FROM vwOvis

    Thanks guys!

    - JH


    - JH

  • Not sure why you want to copy same data into multiple. But have you look into the WHILE statement?

    thanks

  • I'm seperating the columns out due to the size of the database. This is more of a data warehouse than anything else. I'm not sure how to join the tables together when inserting the data. I've been browsing through the BOL, but haven't found anything yet.

    - JH


    - JH

  • I think you're out of luck trying to INSERT to multiple tables. Even if it were defined as a view it would not be an "updatable" view because of the multiple base tables involved.

    A couple of options are a) a stored procedure that does multiple inserts b) an INSTEAD OF trigger

    Cheers,

    - Mark


    Cheers,
    - Mark

  • quote:


    I think you're out of luck trying to INSERT to multiple tables. Even if it were defined as a view it would not be an "updatable" view because of the multiple base tables involved.

    A couple of options are a) a stored procedure that does multiple inserts b) an INSTEAD OF trigger

    Cheers,

    - Mark


Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply