我有一个查询
create procedure pr_InsertFilterOnItemCreation
@zCategoryId int,
@zItemId int,
@zFilterid int
as
declare @productId int
set @productId = (SELECT convert(int,IDENT_CURRENT('item')))
if( @productId<>null)
begin
insert into t_lnk_cat_product_filter_item set cde_catid=@zCategoryId,cde_productid=@productId,cde_filterid=@zFilterid,cde_filteritemid=@zItemId
select 1
end
我收到错误
关键字'set'
附近的语法不正确
答案 0 :(得分:1)
你的INSERT INTO
声明应该这样写:
INSERT INTO t_lnk_cat_product_filter_item
(cde_catid, cde_productid, cde_filterid, cde_filteritemid)
SELECT @zCategoryId, @productId, @zFilterid, @zItemId
而不是:
insert into t_lnk_cat_product_filter_item
set cde_catid = @zCategoryId,
cde_productid = @productId,
cde_filterid = @zFilterid,
cde_filteritemid = @zItemId
答案 1 :(得分:0)
为什么你想在这里设置,只要在表为空时插入值或更新相应的值
insert into t_lnk_cat_product_filter_item
(cde_catid, cde_productid, cde_filterid, cde_filteritemid) values ( @zCategoryId, @productId, @zFilterid, @zItemId)
答案 2 :(得分:0)
要么:
insert into t_lnk_cat_product_filter_item
values(@value1, @value2, @value3)
或
insert t_lnk_cat_product_filter_item
select @value1, @value2, @value3