title: Looping through a group of tables
body: <p>I would like to figure out the best way in SQL Server to find some characters in some tables.
  Would you advise me which is the best way to loop through a group of tables/columns to find some characters using only SQL commands(stored procedures...)?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Example:</p>
  
  <ol>
  <li>Selecting the group of tables/columns:</li>
  </ol>
  
  
  
  <pre><code>SELECT t.name AS table_name
  , c.name AS column_name
  --, ty.Name
  FROM sys.tables AS t
  INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
  INNER JOIN sys.types ty ON c.user_type_id = ty.user_type_id
  where ty.Name = 'uniqueidentifier'
  </code></pre>
  
  <ol start="2">
  <li>Output of the select</li>
  </ol>
  
  
  
  <pre><code> table_name                 column_name
   formset_details_translation    formset_details_translation_id
   formset_details_translation    formset_version_id
   current_schema_instances       original_unique_guid
  
  ...
  </code></pre>
  
  <ol start="3">
  <li>Finding loop. How should I use? cursor?</li>
  </ol>
  
  
  
  <pre><code>for each Table
      For each Column
          select * 
          from tableI
          where columnI = 'XXXX...XXXX'
      End For
  End For
  </code></pre>