If your job is to create reports using SQL chances are you have or will encounter this situation:
You’ve been asked to prepare a report, but the person who has asked for the report simply has a list of fields they want and they have no idea where those fields come from. They may have received previous reports in the past, so they know the fields exist, but cannot provide any of the SQL queries used to create these reports as an example.
You, the developer, may not be familiar with that particular area of the business or associated data sources. Possibly because you typically prepared financial reports and this request has come from the operations or marketing departments.
So the first step is to locate these columns within the database.
The following query will return the Table Name, Schema Name and Column Name from the database.
In the example below all instances where the column name equals CustomerID, OrderID, OrderDate will be returned. Also Column names that contain the word Status or Promotion will also be return. Simply change or add additional columns names as needed.
That should help get you started in preparing the report.