sql检查数据是否被引用
select object_name(ref.fkeyid), col_name(ref.fkeyid, fk.fkey),
object_name(ref.rkeyid), col_name(ref.rkeyid, fk.rkey)
from sysreferences ref
join sysobjects obj on ref.constid=obj.id
join sysforeignkeys fk on obj.id=fk.constid
where object_name(ref.rkeyid)='表名'
and col_name(ref.rkeyid, fk.rkey)='表主键'
select * from 表名 where 表主键=cast(id(值) as varchar(10))

浙公网安备 33010602011771号