title: Mapping CLR Parameter Data
body: <p>I am writing a stored procedure generator and I need to map CLR types to their SQL Server types.</p>
  
  <p>MSDN lists the type mappings at: <a href="http://msdn.microsoft.com/en-us/library/ms131092.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms131092.aspx</a> but I don't want to use a big switch statement to handle the mappings.</p>
  
  <p>Is there a simple way to retrieve the SQL Server type as a string using whatever process is used by System.Data.SqlTypes?</p>
  
  <p>I'd like a method signature like so:</p>
  
  <pre><code>static string GetSqlType(Type clrType)
  {
      ...
      return sqlType;
  }
  </code></pre>
  
  <p>So given the following call:</p>
  
  <pre><code>string sqlType = GetSqlType(1.GetType());
  </code></pre>
  
  <p>sqlType should contain: "int".</p>