update schedule set updatetime=getdate() where +条件 改成: exec('update schedule set updatetime=getdate() where '+条件)
--如果条件是变量中,就用CREATE TRIGGER Trg_PreProductionUpdate ON dbo.PreProduction AFTER UPDATE AS declare @条件 varchar(1000) set @条件='1=1' exec('update schedule set updatetime=getdate() where '+条件) go
我已发现问题,原因不在于那些句子(简单的SQL句子,经检验都是对的) if exists(select * from schedule where +条件) update schedule set updatetime=getdate() where +条件 这样就对了,大家有兴趣的话,可以试一试,这是昨晚我们经理逼出来的, 搞不好不让回家。现在说出来也算增长大家的见识。 (在一次谢谢各位的回答,但是不会有分,因为上面的都试过了,很简单的条件)
改成:
exec('update schedule set updatetime=getdate() where '+条件)
AFTER UPDATE
AS
declare @条件 varchar(1000)
set @条件='1=1'
exec('update schedule set updatetime=getdate() where '+条件)
go
if exists(select * from schedule where +条件)
update schedule set updatetime=getdate() where +条件
这样就对了,大家有兴趣的话,可以试一试,这是昨晚我们经理逼出来的,
搞不好不让回家。现在说出来也算增长大家的见识。
(在一次谢谢各位的回答,但是不会有分,因为上面的都试过了,很简单的条件)