1

I'm using

SELECT DISTINCT
    COLUMN_NAME AS 'ColumnName',
    TABLE_NAME AS  'TableName'
FROM
    INFORMATION_SCHEMA.COLUMNS
WHERE       
    COLUMN_NAME LIKE '%phone%'
ORDER BY    
    TableName, ColumnName;

Now, what I would like to know. How can I view what's written inside that column?

Because I'm searching for names, numbers, emails, etc. Since you may already know that this piece of code only displays the column and table name.

Thank you in advance, and if you need any more information, just ask away!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
GhostyIs1337
  • 33
  • 1
  • 12
  • You would probably need some dynamic SQL to handle this. – Tim Biegeleisen Feb 20 '18 at 14:10
  • You would need to use the data in your results to write new queries *(Dynamic SQL)*. Whatever environment you are using to execute the SQL you've shown would itself write new SQL statements and execute those *separately* from your first query. There is no single query that you can write to find out the tables and columns ***and*** query the contents of those tables and columns at the same time. – MatBailie Feb 20 '18 at 14:10
  • Some adaptation of any of the answers [here](https://stackoverflow.com/q/15757263/4137916) may help. – Jeroen Mostert Feb 20 '18 at 14:12
  • 2
    Seems like an [XYPropblem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) to me. What is the problem you are trying to solve? – Zohar Peled Feb 20 '18 at 14:56
  • Thanks guys. I've downloaded ApexSQL Search, and it works wonderfully. – GhostyIs1337 Feb 21 '18 at 08:18

0 Answers0