I have a database that is not my own, I try to delete from a table but I get this error,
The DELETE statement conflicted with the REFERENCE constraint "FK". The conflict occurred in database "BASE", table "Table".
The statement has been terminated.
I want to know if it is possible by means of a select I can obtain the foreign keys of that database.
I use SQL SERVER 2014
If you occupy the tables let me know in a comment.
You can get the foreign keys (foreign keys) of the database through the system tables. Specifically, the table
sys.foreign_keys
lists all foreign keys in the database.This query returns the names of all foreign keys and the tables they reference:
You can also use the stored procedure
sp_fkeys
to get the foreign keys of a given table: