title: Search all tables for a column AND return max length for the columns
body: <p>I need to make sure all columns that involve usernames have a max length of 140 characters. I'm fairly new to SQL, and I'm curious how you would do this. </p>
  
  <p>I'm starting by returning a list of all tables that contain relevant column names. At the same time, I'd like to also see the character limits for those columns. Here's what I've got so far, except I don't know how to make a variable that will fill in both the Column and Length parts of the query. I'm using SQL Server 2008. </p>
  
  <pre><code>SELECT 
      t.name AS 'Table Name', 
      c.name AS 'Column Name', 
      max(len(%COLUMN_NAME%)) AS 'Max Length'
  FROM sys.tables AS t
  INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
  WHERE c.name LIKE '%COLUMN_NAME%'
  ORDER BY 'Table Name'
  </code></pre>
  
  <p>Solved. Thanks!</p>