Click here to Skip to main content
15,897,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

Will any body tell me how can I bifurcate those tables in sql server 2005, which have data?

Is it possible to get the table names on such parameter!

Actually, I want to get table names with "Select * From Information.Schema.Tables" like query but for those tables which have data or which don't have data.

Pranav
Posted
Updated 26-Feb-11 2:48am
v2

Do you want to select all tables that have rows? See How Many Records Are There in your Database?[^].

That would be:
SQL
SELECT SYS_OBJ.NAME AS "TABLE NAME"
     , SYS_INDX.ROWCNT AS "ROW COUNT"
FROM SYSOBJECTS SYS_OBJ, SYSINDEXES SYS_INDX
WHERE SYS_INDX.ID = SYS_OBJ.ID
  AND INDID IN(0,1) --This specifies 'user' databases only
  AND XTYPE = 'U' --This omits the diagrams table of the database
--You may find other system tables will need to be omitted,
 AND SYS_OBJ.NAME <> 'SYSDIAGRAMS'
AND SYS_INDX.ROWCNT > 0
 
Share this answer
 
Comments
Yusuf 27-Feb-11 8:34am    
Right on the money. Good answer.
I think that you will need to be more specific about what you mean by 'bifurcate'.

My understanding is that it means 'to split into two' and is not a term that I normally associate with databases.

Do you mean that you want to redesign the database schema, or something else?
 
Share this answer
 
Comments
Yusuf 27-Feb-11 8:28am    
using that term bothered me too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900