insert data into several tables

Posted by csetzkorn on Stack Overflow See other posts from Stack Overflow or by csetzkorn
Published on 2010-05-13T13:52:12Z Indexed on 2010/05/13 14:14 UTC
Read the original article Hit count: 215

Filed under:
|
|

Let us say I have a table (everything is very much simplified):

create table OriginalData (
bla char(10) not null
    )

And I would like to insert its data (set based!) into two tables which model inheritance

create table Statements (
        Id int IDENTITY NOT NULL,
ProposalDateTime DATETIME null
    )

create table Items (
        StatementFk INT not null,
       ItemName NVARCHAR(255) null,
       primary key (StatementFk)
    )

Statements is the parent table and Items is the child table. I have no problem doing this with one row which involves the use of IDENT_CURRENT but I have no idea how to do this set based (i.e. enter several rows into both tables).

Thanks.

Best wishes,

Christian

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server