title: Getting Max Decimal places in a float SQL Server 2012
body: <p>I understand float is stored as binary and is a representation in SQL Server.  However, I need the max number of decimal places that are represented in a float column in my table.  I found <a href="https://stackoverflow.com/questions/14715141/how-do-i-count-decimal-places-in-sql#">this link</a> which explains how to get the number of decimal places per row.  However, I can't figure out how to get the max for that result.  In essence this is what I want to do.</p>
  
  <pre><code>SELECT MAX
         (Decimals = CASE Charindex('.', [QUANTITY])
                      WHEN 0 THEN 0
                      ELSE
     Len (Cast(Cast(Reverse(CONVERT(VARCHAR(50), [QUANTITY], 128)
                       ) AS FLOAT) AS BIGINT))
                    END)
  FROM   [schema].[table]
  </code></pre>
  
  <p>This gives me a syntax error after the END. I have tried a sub query and can't seem to get the syntax correct either.  </p>