您当前的位置: 百科371电脑/网络数据库 → 电脑/网络内容 退出登录 用户管理 用户注册
本类热门文章
相关文章
中原建材网
急 sql2005触发器问题

减小字体 增大字体

问题:明天要去公司面试 我这些都忘了 请大家帮我下,谢谢,请大家帮我创建 insert update delete 三个触发器表:create table typetable(typeid int not null primary key identity(1,1),typename nvarchar(20) not null)gocreate table product(productid int not null primary key identity(1,1),productname nvarchar(20) not null,typeid int not null)特别是 AS 后面的语法 怎么写,请写点详细注释 小弟在此谢过  

creat trigger insert_trigger on product for insert
as
begin
declare @id int;
select @id=inserted.typeid from inserted;

if @id not in(select typeid from typetable)
delete from product where typeid=@id;
end;
/*如果新加入的产品记录产品号不在typetable中,则删除该产品记录*/

creat trigger delete_trigger on typetable
as
begin
declare @j_id int
select @j_id=deleted.typeid from deleted
delete from product where typeid=@j_id;
end
/*如果typetable中删除了一个记录,则拥有该类型ID的产品记录都应该删除掉*/

如果你对明天要去公司面试 我这些都忘了 请大家帮我下,谢谢,请大家帮我创建 insert update delete 三个触发器表:create table typetable(typeid int not null primary key identity(1,1),typename nvarchar(20) not null)gocreate table product(productid int not null primary key identity(1,1),productname nvarchar(20) not null,typeid int not null)特别是 AS 后面的语法 怎么写,请写点详细注释 小弟在此谢过这个问题有好的意见或 建议,请留言
[] [返回上一页] [打 印]
电脑/网络评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码

中原建材网 简单版 站长QQ:382546553