inserting into two tables at one time

  • i have a table manufacturerContract with column names

    manuf_contract_id

    manufacturer_id

    per_minute_percent

    rental_percent

    when_dt

    emp_claimed_id

    i have another table manufacturerContractItem table

    manufacturer_id

    company_name

    contact_state

    contact_country

    manuf_contract_notes

    contract_text

    i have to do an insert statement where the manuf_contract_id is auto generated and

    it so happens that when user says submit manufacturerContract table gets values manufacturer_id

    per_minute_percent

    rental_percent

    when_dt

    emp_claimed_id and then ManufacturerContractItem table gets values company_name

    contact_state

    contact_country

    manuf_contract_notes

    contract_text in the same insert statement

    any help???

  • why in the same statement? why not 2 insert statements?

  • quote:


    why in the same statement? why not 2 insert statements?


    how can i do two inserts ???

    i am sorta jumbled up

  • What about:

    
    
    DECLARE @ContractID INT

    INSERT INTO manufacturerContract
    VALUES
    (
    @manufacturer_id, @per_minute_percent, @rental_percent, @when_dt, @emp_claimed_id
    )

    SET @ContractID = @@IDENTITY

    INSERT INTO manufacturerContractItem
    VALUES (
    @ContractID, rest of fields...
    )

    You'll have to post some SQL code if this doesn't help...

    Cheers,

    Jay

  • Thanx jay

    You are awesome

    i got it

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

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