罗列没有主键的表

This is very simple but effective script. It list all the table without primary keys.
USE DatabaseName;
GO
SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName
FROM sys.tables
WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0
ORDER BY SchemaName, TableName;
GO

posted @ 2009-08-28 02:19  卜海清  阅读(175)  评论(0编辑  收藏  举报