I am looking for a generic SQL query that replaces the following procedures:
-- -------------------------------------------------- -- Dropping existing FOREIGN KEY constraints -- -------------------------------------------------- -- -------------------------------------------------- -- Dropping existing tables -- --------------------------------------------------
Example:
The following query resets foreign keys for a specific table. Can it be converted to a common one? (Please do not offer to abandon the entire database, as I do not have permissions.)
SELECT 'ALTER TABLE ' + OBJECT_NAME(parent_object_id) + ' DROP CONSTRAINT ' + name FROM sys.foreign_keys WHERE referenced_object_id = object_id('Student')
Question :
How can I clear a database without dropping it?
Edit : Wait Wait, this is not a duplication issue! Another issue was releasing rows (or just data) that preserve relationships and tables. I am trying to delete all data, tables and relationships without dropping the database!
source share