Hmmmm, doesn't work for me ... what am I missing?
===================================
select @@version
go
----------------------------------------------------
Adaptive Server Enterprise/15.7/EBF 22230 SMP SP121
sp_displaylogin
go
... snip ...
Configured Authorization:
sa_role (default ON)
sso_role (default ON)
replication_role (default ON)
mon_role (default ON)
Locked: NO
... snip ...
use tempdb
go
create table t1 (a int, b int)
go
alter table t1 add primary key (a)
go
create table t2 (a int references t1(a), c int)
go
insert t2 values (1,5)
go
Msg 546, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Foreign key constraint violation occurred, dbname = 'tempdb', table name = 't2', constraint name = 't2_a_345657311'.
Command has been aborted.
set disable_ri_check on
go
insert t2 values(1,5)
go
Msg 546, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Foreign key constraint violation occurred, dbname = 'tempdb', table name = 't2', constraint name = 't2_a_345657311'.
Command has been aborted.
insert t1 values (1,5)
insert t2 values (1,7)
go
set disable_ri_check on
go
delete t1
go
Msg 547, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Dependent foreign key constraint violation in a referential integrity constraint. dbname = 'tempdb', table name = 't1', constraint name = 't2_a_345657311'.
Command has been aborted.
-- and just in case the logic is reversed
set disable_ri_check off
go
delete t1
go
Msg 547, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Dependent foreign key constraint violation in a referential integrity constraint. dbname = 'tempdb', table name = 't1', constraint name = 't2_a_345657311'.
Command has been aborted.
===================================