drop table a drop table b CREATE TABLE [dbo].[b] ( [bv] [int] not NULL primary key ) ON [PRIMARY] GOCREATE TABLE [dbo].[a] ( [av] [int] NULL ,avr int REFERENCES b(bv) ON DELETE CASCADE ) GOinsert into b select 2 insert into a select 1,2select * from b select * from adelete from b select * from b select * from a数据库创建好了就行了
c#.sqlserver都提供了事务功能
drop table b
CREATE TABLE [dbo].[b] (
[bv] [int] not NULL primary key
) ON [PRIMARY]
GOCREATE TABLE [dbo].[a] (
[av] [int] NULL
,avr int REFERENCES b(bv) ON DELETE CASCADE
)
GOinsert into b select 2
insert into a select 1,2select * from b
select * from adelete from b select * from b
select * from a数据库创建好了就行了