title: Extract float from String/Text SQL Server
body: <p>I have a Data field that is supposed to have floating values(prices), however, the DB designers have messed up and now I have to perform aggregate functions on that field. Whereas 80% of the time data is in correct format,eg. '80.50', sometime it is saved as '$80.50' or '$80.50 per sqm'.</p>
  
  <p>The data field is nvarchar. What I need to do is extract the floating point number from the nvarchar. I came accross this: <a href="http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/" rel="nofollow">Article on SQL Authority</a></p>
  
  <p>This, however, solves half my problem, or compound it, some might say. That function just returns the numbers in a string. That is '$80.50 per m2'will return 80502. Obviously that wont work. I tried to change the Regex from =>
      PATINDEX('%[^0-9]%', @strAlphaNumeric) to=>
      PATINDEX('%[^0-9].[^0-9]%', @strAlphaNumeric)
  doesnt work. Any help would be appreciated.</p>