Results 1 to 2 of 2

Thread: Primary key search tool needed

  1. #1
    Jim Story Guest

    Primary key search tool needed

    I need to search through a database that has a large number of tables to see if each table has an index that is based on the
    primary key. I need this information in order to determine whether I can setup database replication or not. I believe all tables
    involved with a replication need to be indexed on the primary key. Does anyone know of a stored procedure or command file that
    will provide this information for me in a timely manner? I've used the sp_pkeys stored procedure but it is very time consuming
    running this against one table at a time.

  2. #2
    Hubert Endl Guest

    Primary key search tool needed (reply)

    Below is a SP that gives you the Info about
    PK - Name and Columns

    You just have to go thru the Result an find out the tables where the SP didn't give you any information.

    I hope that helps

    happy new year.

    Hubert



    IF EXISTS ( SELECT Name FROM Sysobjects WHERE Type = 'P' AND Name = 'Sys_Show_Index' )
    DROP PROCEDURE Sys_Show_Index
    GO

    CREATE PROCEDURE Sys_Show_Index
    AS


    BEGIN

    DECLARE
    @Table_Name Char(50)


    DECLARE All_Tables_Cur CURSOR FOR
    SELECT Name
    FROM Sysobjects WHERE Type = 'U'
    ORDER BY Name

    OPEN All_Tables_Cur

    FETCH NEXT FROM All_Tables_Cur INTO @Table_Name

    WHILE @@FETCH_STATUS = 0
    BEGIN

    SELECT @Table_Name

    EXEC SP_PKeys @Table_Name

    FETCH NEXT FROM All_Tables_Cur INTO @Table_Name
    END

    CLOSE All_Tables_Cur
    DEALLOCATE All_Tables_Cur


    END
    GO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •