Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding all tables with no Key Index
Message
From
30/11/2005 10:32:56
 
 
To
30/11/2005 10:29:51
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01073246
Message ID:
01073249
Views:
12
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.
Previous
Reply
Map
View

Click here to load this message in the networking platform