I'm searching for a generic SQL query that replaces the following procedures:
-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------
-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------
Example:
The following query drops foreign keys for specific table. Can it be converted to a generic one? (Please don't suggest dropping the whole database as I don't 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 empty a database without dropping it?
Edit: Wait Wait, it's not a duplication question! The other question was about emptying rows ( or data ONLY ) keeping relations and tables. I'm trying to drop all data, tables & relations without dropping the database itself!