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.