Contents tagged with MS SQL find table by value T-SQL

  • MS SQL find table by data record.

    Some time it happens that you need to find some string in the MS SQL database. 

    Here I found very helpful ms sql code which helps to find any string in database.

    At stackoverflow I found optimization of that script, which I copy/pasted below:

    CREATE PROC SearchAllTables


    @SearchStr nvarchar(100)




    -- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.

    -- Purpose: To search all columns of all tables for a given search string

    -- Written by: Narayana Vyas Kondreddi

    -- Site:

    -- Tested on: SQL Server 7.0 and SQL Server 2000

    -- Date modified: 28th July 2002 22:50 GMT

    DECLARE @Results TABLE(ColumnName nvarchar(370), ColumnValue … more