Easier/better way to find column with data value

  • I recently wrote the following generator script because I did not know of a simplier way to find the table/column that held a particular value. Does anyone know a better way?

    SELECT 'select * from ' + TABLE_NAME + ' where LOWER([' + column_name + ']) = ''family_data.txt'''

    FROM INFORMATION_SCHEMA.COLUMNS

    WHERE table_name NOT LIKE '%_backup'

    AND table_name NOT LIKE 'gen%'

    Thanks.

    <><
    Livin' down on the cube farm. Left, left, then a right.

  • Tobar take a look at this thread, or search for "sp_UGLYSEARCH" (with quotes)

    http://www.sqlservercentral.com/Forums/Topic1221552-1292-1.aspx

    that's a proc i wrote to do exactly what you are asking: find specific values in a database, where you don't know the table or column name.

    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!

  • Thanks

    <><
    Livin' down on the cube farm. Left, left, then a right.

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

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