create table mylog
(
id int not null primary key,
uid char(10) not null,
operateDate datetime not null,
type varchar(20) not null)
…………………………
create trigger Del on employee
for delete
as
begin
declare @id int,@maxID int
select @maxID=isnull(max(id),0) from mylog
select @[email protected]+1
insert into mylog values(@maxID,current_user,getdate(),'delete')
end
……………………….
delete from employee where emp_no='E1002'
select * from mylog
drop trigger Del
————————————————————————————
中的 select @maxID=isnull(max(id),0) from mylog
select @[email protected]+1
insert into mylog values(@maxID,current_user,getdate(),'delete')
这几句什么意思,求高手解释一下
------解决方案--------------------
- SQL code
select @maxID=isnull(max(id),0) from mylog---查询mylog中最大值的id,如果是NULL话,就为0 select @[email protected]+1[email protected]+1 insert into mylog values(@maxID,current_user,getdate(),'delete')--向这个表中添加一条记录
------解决方案--------------------
把mylog中最大的id,如果查询到的最大的id为null就用0 代替,[email protected]
[email protected],在把数据插入到表mylog 中。其中getdate()表示系统当前时间
------解决方案--------------------