Refine objects in SQL

  • Hi, I need refine the objects in a database. For example, I have 404 tables, someone don't use. How can I do by identify them? How can I identify the tables, where no rows?

    Thanks....

  • I would be careful of removing even tables that have no rows. I have seen many of those used in queries throughout an application. If the table is no longer present, then the app will start throwing errors.

    Declare @DatabaseIDsmallint

    Set @DatabaseID = DB_ID('yourdbname')

    select db_name(database_id) as DBName,OBJECT_NAME(object_id) as ObjName, index_id,record_count

    from sys.dm_db_index_physical_stats(@DatabaseID,null,null,null,'sampled')

    where index_id in (0,1)

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Hi, thanks..... now about Stored Procedures: Can I know which is the last access datetime of stored procedure?

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

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