Droping or moving old tables

  • How to validate the last updated date for each of the tables.

    I want you to check if the tables are updated in real-time

    ·How to check if the tables going to move or delete have any dependencies.

    ·Please include any suggestions for how to drop these tables.

    The reason for moving or deleting these tables is we are running out of space on that server.

  • You can check the dependencies of the table using the Catalog Views:

    USE AdventureWorks2008R2;

    GO

    SELECT referencing_schema_name,

    referencing_entity_name,

    referencing_id,

    referencing_class_desc,

    is_caller_dependent

    FROM sys.dm_sql_referencing_entities('[Person].[PersonPhone]', 'OBJECT');

    You can check the index usage stats, but if you yourself have selected from the table your stats will be polluted. These stats are reset after a service restart so if you check these stats after a restart and do not touch the table yourself you might get lucky to know if anyone is accessing it.

    USE AdventureWorks2008R2;

    GO

    SELECT *

    FROM sys.dm_db_index_usage_stats

    WHERE OBJECT_NAME(object_id) = 'Department'

    AND OBJECT_SCHEMA_NAME(object_id) = 'HumanResources';

    You may want to setup a Trace to look for queries referencing the table and run it for a few months. Else you could risk it, export the table to a file using bcp and the native data format (fastest), save off the DDL for the table with all indexes and permissions, and drop the table.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Thanks for your reply.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply