How to search for a specific string in all columns within all tables of a SQL Server database?

后端 未结 3 434
北荒
北荒 2021-01-28 16:30

We want to search for a string (ie. \"Hello World\") in all our database that has about 120 tables. We thought about doing a dump like mysql dump but it came out in a weird bak

相关标签:
3条回答
  • 2021-01-28 16:40

    How to search all columns of all tables in a database for a keyword

    0 讨论(0)
  • 2021-01-28 16:52

    Is this just for a one-off, or something you want to do regularly?

    If it's a one-off, how about using the export data wizard to export the tables out to CSV files (assuming you're using SQL Server, although I'm sure most databases have equivalents).

    Once you've done this you can just do a 'Find Files' in explorer to find all occurrences?

    It's a bit dirty - but it'll work!

    0 讨论(0)
  • 2021-01-28 17:05

    No it possible and easy to write a script to do this.

    Suggestions: I think you have to use some cursors and use some of these objects to write your script

    1. sys.databases
    2. INFORMATION_SCHEMA.TABLES or sys.tables
    3. INFORMATION_SCHEMA.COLUMNS or sys.columns

    Once you have these things in place, searching Hello World under all columns would be more simple

    0 讨论(0)
提交回复
热议问题