Search all tables for Primary key value

  • Hi,

    I found a few 'SearchAllTables' scripts out there to help me find a value in any table/column/row of any Database.

    My problem is that none of these database search queries seem to look at primary key values.

    The value I'm looking for is a primary key - I need to find all the other tables that have this primary key value.

    Anybody know how I could accomplish this?

  • krypto69 (2/26/2015)


    Hi,

    I found a few 'SearchAllTables' scripts out there to help me find a value in any table/column/row of any Database.

    My problem is that none of these database search queries seem to look at primary key values.

    The value I'm looking for is a primary key - I need to find all the other tables that have this primary key value.

    Anybody know how I could accomplish this?

    Do you mean primary key data or primary key name?

    Can you give an example of what you mean?

  • krypto69 (2/26/2015)


    Hi,

    I found a few 'SearchAllTables' scripts out there to help me find a value in any table/column/row of any Database.

    My problem is that none of these database search queries seem to look at primary key values.

    The value I'm looking for is a primary key - I need to find all the other tables that have this primary key value.

    Anybody know how I could accomplish this?

    change the datatype of your script to search all tables to match the datatype expected(ie int?);

    then you can search all tables for a column with the integer value of 98949;

    you might want to also modify the script so that it joins on sys.indexes where idnexid = 1 and sys.index_columnsas well;

    then you get only PK values.

    it depends on your schema, obviously.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply