我有一个表Test
,其中包含
InveCode varchar(50)
itemid numeric(2)
rowid numeric identity,
purdate date
我在这张桌子上有一个触发器。
Create trigger [dbo].[TrgInveCode]
on [dbo].[test]
after insert
as
declare @itemid numeric(10)
declare @total numeric(10)
declare @rowid numeric(18)
declare @Date date
select @itemid = i.itemid from inserted i
select @rowid = i.rowid from inserted i
select @Date = i.purdate from inserted i
select @total = count(itemid)
from test
where itemid = @itemid and year(purdate) = year(@date)
update test
set invecode= cast(@itemid as varchar(50)) + '-' + cast(year(@Date) as varchar(50)) + '-' + cast(@total as varchar(50))
where rowid = @rowid
当我使用此命令时
insert into test(itemid, purdate, buyingyear)
output inserted.invecode
values(@itemid, @purdate, @buyingyear)
在vb.net中,我收到此错误:
如果语句包含没有INTO子句的OUTPUT子句,则DML语句的targer表'test'不能具有任何已启用的触发器。
答案 0 :(得分:0)
您不能在具有触发器的表上使用$ counter=$(grep -Eo '(^|[^0-9]|\b)[0-9]{3}(\b|[^0-9]|$)' numbers.dat | grep -Eo '[0-9]{3}' | wc -l)
# or
$ counter=$(grep -Eo '(^|[^0-9]|\b)[0-9]{3}(\b|[^0-9]|$)' <<< "${str}" | grep -Eo '[0-9]{3}' | wc -l)
$ echo "${counter}"
9
子句。
Cannot use UPDATE with OUTPUT clause when a trigger is on the table
您别无选择,只能OUTPUT
结果OUTPUT
一个表变量。