title: Get length of Columns using SQL Server Management Objects (SMO)
body: <p>I'm writing T4 templates to generate CRUD stored procs etc</p>
  
  <p>I am looping through the columns of a table using SMO:</p>
  
  <pre><code>For Each column As Column In table.Columns
      WriteLine("@" &amp; column.Name &amp; " " &amp; column.DataType.Name &amp; ", ")
  Next
  </code></pre>
  
  <p>My question is simply how do I find the Length of a varchar column? There doesn't appear to be any Length / MaxLength etc property on the column.</p>
  
  <p>I'm using <a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.column_members.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.column_members.aspx</a> as a reference</p>