I have 70+ tables in my azure sql database. I want to delete data from all these tables except some by bypassing the foriegn keys. Is there any script available to do the same because some table may have complex and long foreign key relationships.
I have gone through several links but not getting exact solution to automate this process.
Does anyone know how I could proceed?
Sample data:
Here I have Employee and Customer as master table and other tables are my child tables before truncating child table you need to drop the foreign key constraints otherwise you will face this error.
You can use dynamic SQL script to perform this sample script
Output: