MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

ESSENTIALS: Home | Tips | Search | Categories | Top 10 | Products | Authors | Blogs | Forums | Webcasts | Advertise | About
Query or make a select statement in a Database where tables are NULL or emty -

in Search

Query or make a select statement in a Database where tables are NULL or emty

Last post 06-13-2008 12:29 PM by tosscrosby. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-12-2008 3:20 PM

    • Pablo
    • Top 500 Contributor
    • Joined on 06-12-2008
    • Posts 1

    Query or make a select statement in a Database where tables are NULL or emty

    Need your help

    Is there any sentence or select statement where as resulsets bring me the names of the tables that are NULLS or emty.

    I appreciate yor help

  • 06-13-2008 12:29 PM In reply to

    Re: Query or make a select statement in a Database where tables are NULL or emty

    If I understand this correctly, you want all tables the have no rows of data, correct? If so, this will work in SQL 2000 (I don't have SQL 2005 syntax). It will run for all user tables within a database.

     SELECT o.name, i.rowcnt, getdate() as RunDate  FROM  sysobjects o,   sysindexes i
        WHERE i.id = o.id AND indid IN(0,1) AND xtype = 'u' and i.rowcnt = 0

     

Page 1 of 1 (2 items)