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:32:56
 
 
À
30/11/2005 10:29:51
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01073246
Message ID:
01073249
Vues:
13
CORRECTION:

I was trying something else. This is the code I would like considered(the EXEC line is different):

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_pkeys @TableName ))) IS NULL
PRINT @TableName

FETCH NEXT FROM TableNameCursor
INTO @TableName
END

CLOSE TableNameCursor
DEALLOCATE TableNameCursor
GO


>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform