Home Forums SQL Server 2008 T-SQL (SS2K8) Using 2 TVPs in a stored proc to insert into 2 related tables RE: Using 2 TVPs in a stored proc to insert into 2 related tables

  • I agree the OUTPUT clause is the way to go.

    Something along these lines should work

    Declare @Results Table

    (

    RequestQueueID bigint not null,

    ScopeRequestID bigint not null

    )

    Insert Into dbo.RequestQueue

    Select

    From [dbo].[udtt_Request]

    Output Inserted.RequestQueueID, ScopeRequestID Into @Results

    Insert Into dbo.RequestProperties

    Select , R.RequestQueueID

    From [dbo].[udtt_RequestProperties] As RP

    Inner Join @Results As R ON Rp.ScopeRequesID = R.ScopeRequesID