In this post, I am going to share one of the important script for SQL Serve DBA to find a list of tables which have disable foreign keys.
In any RDBMS system, the rule of data integrity is mandatory because it ensures the quality of data.
In our organization, database developers sometime disable the foreign key constraint because they required to insert test data or required to import non-related data.
After this testing, there are 90% chance of forgetting to enable foreign key constraint again to maintain further data integrity.
Using below script,the DBA can find a list of tables which have disable foreign key constraints.
[s].[name] + '.' + [t].[name] AS TableName
FROM [sys].[tables] AS t
INNER JOIN [sys].[schemas] AS s
ON [t].[schema_id] = [s].[schema_id]
SELECT 1 FROM [sys].[foreign_keys] AS fk
WHERE [fk].[parent_object_id] = [t].[object_id]
AND [fk].[is_disabled] = 1
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.