snippetsqlMinor
How to hide/disable tables without dropping them to check redundancy?
Viewed 0 times
tableswithoutdisabledroppingredundancyhowcheckthemhide
Problem
I have to maintain and extend an old legacy system which contains webservice methods and database tables that are no longer used. Since I’m not entirely sure that the tables are really redundant, I’m afraid to drop them.
Is there any other way to achieve the same effect (tables cannot be used any more) without dropping them? My idea was to transfer them to a different schema (e.g.,
Is there any other option or are there any drawbacks to the schema approach?
Is there any other way to achieve the same effect (tables cannot be used any more) without dropping them? My idea was to transfer them to a different schema (e.g.,
Deleted) from the current default, dbo.IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'Deleted')
BEGIN
EXEC('CREATE SCHEMA Deleted')
END
ALTER SCHEMA Deleted TRANSFER dbo.TableName;Is there any other option or are there any drawbacks to the schema approach?
Solution
Is there any other way to achieve the same(tables cannot be used anymore) without dropping them?
A schema change is a very fast operation - just metadata change is required. The original idea I got was from Aaron Bertrand's blog - Schema Switch-A-Roo.
You can follow the steps from my answer here
Obviously there are other methods like sp_rename N'old table', N'new table' or just deny permissions to the table.
A schema change is a very fast operation - just metadata change is required. The original idea I got was from Aaron Bertrand's blog - Schema Switch-A-Roo.
You can follow the steps from my answer here
Obviously there are other methods like sp_rename N'old table', N'new table' or just deny permissions to the table.
Context
StackExchange Database Administrators Q#138724, answer score: 7
Revisions (0)
No revisions yet.