sql-server - 将声明的类型表变量插入另一个表?
问题描述
尝试将声明的变量 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' 附近的语法不正确”
解决方案
推荐阅读
- ios - Swift:使用`var`会导致编译器警告,使用`let`会导致编译器错误?
- javascript - 悬停时播放声音
- angular - 函数更新与 [(ngModel)] 绑定的数组中的所有对象
- node.js - 如何从发布请求中检索数据
- php - Laravel 登录时重定向到不同的 URL
- android-studio - 当 minifyEnabled 为 true 时,Android Studio 构建卡住
- java - 插入 Google 日历的预定 WebScraper
- linux - 为什么 sudo 用户时 pssh 命令不起作用?
- haskell - 浮点 SMT 逻辑是否比真实逻辑慢?
- elasticsearch - 将 Cloudtrail gzip 日志从 S3 发送到 ElasticSearch