Thursday, September 15, 2011

Find Table Count and Tables without Primary Key in MS SQL

Post shows how you can Find total number of Tables in a database and the Tables which are without Primary Key in MS SQL

Amplify’d from

Few days ago while working on MS SQL 2008 Transactional Replication I have faced following two issue

1) To find out the total number of tables to verify that Primary Server and Secondary server have same table count.

2) Tables without Primary key: After replication setup I have found that some tables were not replication. When I checked the logs it showed following error

This table cannot be published because it does not have a primary key column. Primary key columns are required for all tables in transactional publications.

1) Find Number of Tables:

a) Open MSSQL management studio and login using SA password or Administrator access.

b) Click on “New Query” and select the database using following command

use <database name>


About This Blog

The Windows Registry is a database which stores settings and options for Microsoft Windows operating systems. It contains normally information and settings for hardware, operating system software, most non-operating system software, and per-user settings. Registry is used to optimize the security, enhance the functionality, modify the functioning of any software OR settings and many more.

In this blog I have tried to collect all the tweaks and hacks available on various website. I have tested many of these hacks before posting but still I would suggest you to take backup of your registry before trying any of these tweaks and if anything goes wrong while trying these hacks I or this blog will not be held responsible.

  © Blogger templates The Professional Template by 2008

Back to TOP