表table中有a,b,c,d列a(char)
b(datetime)
c(datetime)触发器的条件是:
当更新table时,若b = '' ,a显示为'无数据'
若b <> '' 且b<c时,a显示为'finish',否则显示'unfinished'
b(datetime)
c(datetime)触发器的条件是:
当更新table时,若b = '' ,a显示为'无数据'
若b <> '' 且b<c时,a显示为'finish',否则显示'unfinished'
cast('' as datetime)
for update
as
update inserted
set a='无数据'
where b = '' update inserted
set a=示'unfinished'
where b <c and b<>'' update inserted
set a='finish'
where b <>''
and b>=c
汗。我的SQL2000显示的是<null>。刚学SQL,很多知识不清楚,正在看书中。这个问题现在急用,所以就来求高手解答了,救急。
create table T_update on T
instead of update
as
set nocount on ;
delete t where checksum(*)in (select checksum(*) from deleted )insert T(a,b,c,d)
select [a]=case when b is null then '无数据' when b<c then 'finish' else 'unfinished' end,b,c,d
from inserted
写在存储过程里
create procedure test
@a char(100)
@b datetime
@c datetime
as
begin
if @b = ''
begin
set @a = '无数据'
end if @b <> '' and @b < @c
begin
set @a = 'finish'
end if @b <> '' and @b >= @c
begin
set @a = 'unfinished'
end update [Table]
set a = @a,
b = @b,
c = @c
where
..............end
instead of update
as
set nocount on ;
delete t where checksum(*)in (select checksum(*) from deleted )
insert T(a,b,c,d)
select [a]=case when b is null then '无数据' when b<c then 'finish' else 'unfinished' end,b,c,d
from inserted
@a char(100)
@b datetime
@c datetime
as
begin
if @b = '' or @b is null --<Null>
begin
set @a = '无数据'
end if @b <> '' and @b < @c
begin
set @a = 'finish'
end if @b <> '' and @b >= @c
begin
set @a = 'unfinished'
end update [Table]
set a = @a,
b = @b,
c = @c
where
..............end