首页 > 解决方案 > 将声明的类型表变量插入另一个表?

问题描述

尝试将声明的变量 Ids 插入另一个表时收到错误消息。我将如何纠正这一点?

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

错误消息“关键字 'Select' 附近的语法不正确”

标签: sql-server

解决方案


推荐阅读