0

I receive an error when trying to insert the declared variable Ids into another table. How would I correct this?

ALTER PROCEDURE [dbo].[tbl_Update] 
    @id int,
    @description nvarchar(50),
    @price decimal(12,7),
    @statusId int,
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    Update tbl
    set
    description=@description,
    price=@price,
    statusId=@statusId
    where id = @id

    --Once submitted values will map to adminEdm 
    if (@statusId = 1)

    --Every subform will be created and their ids will be

    Declare @generalId table (id int)
    insert into tblGeneral 
    output inserted.id into @generalId(id)
    default values

    Declare @categoryId table (id int)
    insert into tblCategory
    output inserted.id into @categoryId(id)
    default values

    --ERROR when inserting
    Insert into tblParent(generalId, categoryId)
    values(Select id from @generalId, Select id from @categoryId)

END

Error message "Incorrect syntax near the keyword 'Select'"

KamSami
  • 387
  • 1
  • 4
  • 14
  • 1
    Are you trying to insert single row into each table (tblGeneral, tblCategory) or multiple rows at once? Which code is supposed to be affected with that dangling `if (@statusId = 1)`? Everything till the end of sp? – Ivan Starostin Mar 04 '19 at 14:21
  • A single row into the tblParent and if the statusId = 1 everything under should be affected. – KamSami Mar 04 '19 at 14:37

0 Answers0