| 急 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 后面的语法 怎么写,请写点详细注释 小弟在此谢过这个问题有好的意见或
建议,请留言
|
|
[]
[返回上一页]
[打 印]
|
|
|