title: Get column creation datatype for declaration
body: <p>Is there a quick way to get a string containing the sql datatype required for a column declaration, based on column/column information in the database.</p>
  
  <p>For example I'd want strings returned such as:</p>
  
  <pre><code>varchar(200)
  datetime
  numeric(35,5)
  </code></pre>
  
  <p>Obviously I can get the information required to generate this myself from <code>SYS.COLUMNS</code> or from <code>INFORMATION_SCHEMA.COLUMNS</code> and start handling those, but I wanted a (preferably MS provided) way to turn the datatype/maxlength/precision/scale information into the column declaration data type automatically.</p>
  
  <p>I would guess that if there is a standard way to do this it would handle all possible data types, which would be a pain to try to cover manually.</p>
  
  <p>EDIT: Sorry - It seems I've not been clear enough on what I want.</p>
  
  <p>As an example, when you script a table for <code>CREATE</code> in SSMS, the resulting script contains the datatypes in the formats I want. Is there a way to get these automatically?</p>
  
  <p>EDIT:</p>
  
  <p>OK: One more go:</p>
  
  <p>What I want is a bit like this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/2683686/sql-server-declaring-variable-type-based-on-a-column-type">Declaring variable type based on a column type</a></p>
  
  <p>The difference is that I don't mind having to declare the variable dynamically as I'm working with dynamic SQL already.</p>