Voici 3 scripts SQL permettant de lister l'ensemble des tables d'une base de données ne possédant pas de clé primaire.
Version SQL Server 2005 :
SELECT NAME FROM sys.TABLES WHERE NOT EXISTS (SELECT * FROM sys.key_constraints WHERE sys.TABLES .object_id = sys.key_constraints.parent_object_id)
Version SQL Server 2000, 2005 :
SELECT NAME FROM sysobjects WHERE type = 'U' AND id NOT IN (SELECT parent_obj FROM sysobjects WHERE type = 'k')
ou, plus simple
SELECT NAME FROM sysobjects WHERE OBJECTPROPERTY(id, 'IsPrimaryKey')=0 AND TYPE='U'