0

In our database we have a number of tables that have non-descriptive columns names e.g. (Attribute1, Attribute2....Attribute60 etc).

What I am wanting to know is if given a particular piece of information e.g. I know that a Job Code could be "123456", but I do not know what column in our database relates to Job Code, is it possible using a query to find out which column in which table contains data that is similar to that of 123456?

I am fairly confident my colleague used to have a query to achieve this but he has since left our organisation and I cannot seem to find his query.

Appreciate any help I can get!

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 1
    I can't imagine anything you write is going to perform well unless there are specific columns to check. Where do you start searching an entire db, including non-indexed data, for a pattern? I think you're better off manually reviewing the data and create a mapping with some logical names. – Just Aguy Mar 08 '13 at 02:40
  • 1
    http://stackoverflow.com/questions/12824577/how-to-search-all-text-fields-in-a-db-for-some-substring-with-t-sql – Jakub Kania Mar 08 '13 at 02:52
  • How do I find a value anywhere in a SQL Server Database?http://stackoverflow.com/questions/436351/how-do-i-find-a-value-anywhere-in-a-sql-server-database – Aleksandr Fedorenko Mar 08 '13 at 07:50
  • Does anyone know of something similar that works in Teradata as opposed to SQL Server? – Chris Hollier Oct 24 '13 at 04:49

1 Answers1

-1

sp_search_code is what I use to find any code items which are in the DB; however, what you need is a redgate tool which will index the db and help you search its contents. I will suggest as Just Aguy did, that you spend some time cleaning up those generic column names and any gen table names for that matter, good luck.

http://vyaskn.tripod.com/sql_server_search_stored_procedure_code.htm

parkerw262
  • 336
  • 2
  • 4