Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding all tables with no Key Index
Message
De
30/11/2005 10:29:51
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Finding all tables with no Key Index
Divers
Thread ID:
01073246
Message ID:
01073246
Vues:
51
I have tried the code below to get a list of all tables in a legacy database that have no key index, and I have looked many places in BOL for different possibilities, but am unable to come up with the solution as of yet. Is the code below possible with some modification? If not, what might be a better method?

DECLARE @TableName VARCHAR(100)
DECLARE TableNameCursor Cursor FOR
SELECT [name]
FROM sysobjects
WHERE xtype = 'U'
OPEN TableNameCursor
FETCH NEXT FROM TableNameCursor
INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN

If ((EXEC sp_primarykeys WMSDBPRI)) IS NULL
PRINT @TableName

FETCH NEXT FROM TableNameCursor
INTO @TableName
END

CLOSE TableNameCursor
DEALLOCATE TableNameCursor
GO
Thank You

Rollin Burr

Politicians and diapers have one thing in common. They should both be changed regularly, and for the same reason.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform