how to find particular table has no records

Posted by Vanchi050585 under Sql Server on 8/11/2010 | Views : 3831 | Status : [Member] | Replies : 4
hi all,

how to find particular table has no records and how to find particular column of table has no values.

pls send the query

Thanks

Thanks
tvn



Responses

Posted by: Shankul2784 on: 8/11/2010 [Member] Bronze

Up
0
Down

Hi,

For how to find particular table has no records, you can use the following query

select count(*) from tablename

For how to find particular column of table has no values, use the following query

select count(columnname) from tablename where columnname is not null and columnname <> ''


I hope, this will help you.

Thanks & Regards,

Shailesh

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vanchi050585 on: 8/11/2010 [Member] Starter

Up
0
Down
thanks

Thanks
tvn

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 8/11/2010 [Member] [MVP] Silver

Up
0
Down
Hi

To findout in all tables in current database.

1. To findout what are all the table(s) doesn't have Record(s) in current Database.

SELECT O.[NAME] 'Table Name' FROM SYS.SYSINDEXES I JOIN SYS.OBJECTS O
ON(I.id = O.[object_id])
WHERE O.[TYPE] = 'U'
GROUP BY O.[NAME]
HAVING SUM(I.[ROWS]) =0
ORDER BY O.[NAME]

2. To findout what are all the columns in all table is not possible with direct way. (You need some workarround here).

Cheers

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shankul2784 on: 8/11/2010 [Member] Bronze

Up
0
Down


very thankful to updating the knowledge.

Thanks & Regards,

Shailesh

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response