If you don't mind rounding, you can do what you want in one step:

ALTER TABLE dbo.Stringy 
    ALTER COLUMN latitude decimal (9, 6) 
    WITH (ONLINE = ON); -- SQL Server 2016 onward

This can be an online operation in SQL Server 2016 or later.

If you need to truncate (not round) things are more tricky. You would need to perform a calculation like:

SELECT 
    CONVERT
    (
        decimal(9,6), 
        ROUND
        (
            CONVERT
            (
                decimal(10, 7), 
                S.latitude
            ), 
            6, -- decimal places
            1  -- truncate, don't round
        )
    )
FROM dbo.Stringy AS S;

If there might be some non-numeric values in there, use TRY_CONVERT instead and accept nulls in the new column, or provide a default value with ISNULL.

If the objective is to save space, you'll need to rebuild the table or run DBCC CLEANTABLE (perhaps in small batches until complete) to achieve that. The dropped variable-length string column will continue to take up space until then.

Answer from Paul White on Stack Exchange
🌐
MSSQLTips
mssqltips.com › home › sql format number with cast, convert and more
SQL Format Number with CAST, CONVERT and more
October 31, 2025 - SELECT CONVERT(int, 'maybe int') as int_ GO SELECT TRY_CONVERT(int, 'maybe int') as try_convert_int GO · The SQL ROUND function may be useful if you want to round the number of decimal places.
🌐
Oracle
forums.oracle.com › ords › apexds › post › conversion-of-number-to-decimal-4399
Conversion of NUMBER to DECIMAL
May 7, 2007 - I am querying a field that is a NUMBER(3,1) data type and I need to have it returned as a DECIMAL with two decimal points. For example, 5 would be returned as 5.00. Thanks, Sushi Lover
Discussions

Converting Long Integer to decimal in SQL Server - Software & Applications - Spiceworks Community
Hi,How can I convert Long Integer value into decimal in SQL Server. I have a field in one table which is long integer data type but the display format for that data on the window is decimal. Users can enter the information in decimals but tables saves in Integer. More on community.spiceworks.com
🌐 community.spiceworks.com
0
September 7, 2009
How to convert Expression to decimal in SQL or PL/SQL - Databases & Queries - Spiceworks Community
HI All, I am new to this group, i need help, my requirement is: In Dimention feild/column (varchar2(50)) need to convert in decimal i.e. Expression to decimal (note: source data is not in proper format for some records, but we need to get the result for some of the records) I tryied with this ... More on community.spiceworks.com
🌐 community.spiceworks.com
0
May 18, 2007
sql server - Convert string numeric values with comma as decimal separator to NUMERIC(10, 2) - Database Administrators Stack Exchange
I have an SQL table of varchar ... comma as decimal separator) ... (If you are using SQL Server 2012 or newer, please see @wBob's answer for a cleaner approach. The approach outlined in my answer below is only required if you are using SQL Server 2008 R2 or older.) You don't need (or want) the thousands' separator when converting to NUMERIC, ... More on dba.stackexchange.com
🌐 dba.stackexchange.com
October 14, 2015
How to convert integer to decimal in SQL Server query? - Stack Overflow
A column height is integer type in my SQL Server table. I want to do a division and have the result as decimal in my query: Select (height/10) as HeightDecimal How do I cast so that the HeightDeci... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Spiceworks
community.spiceworks.com › software & applications
Converting Long Integer to decimal in SQL Server - Software & Applications - Spiceworks Community
September 7, 2009 - Hi,How can I convert Long Integer value into decimal in SQL Server. I have a field in one table which is long integer data type but the display format for that data on the window is decimal. Users can enter the informati…
🌐
Spiceworks
community.spiceworks.com › programming & development › databases & queries
How to convert Expression to decimal in SQL or PL/SQL - Databases & Queries - Spiceworks Community
May 18, 2007 - HI All, I am new to this group, i need help, my requirement is: In Dimention feild/column (varchar2(50)) need to convert in decimal i.e. Expression to decimal (note: source data is not in proper format for some records, but we need to get the result for some of the records) I tryied with this Ex: select to_char(to_number((11.0+11.0)/2), ‘999.99’) from dual; its its giviving error : ORA-01722: invalid number but its very difficult to find in lacks of record kindly send me the code, how to do this...
🌐
W3Schools
w3schools.com › sql › sql_datatypes.asp
SQL Data Types for MySQL, SQL Server, and MS Access
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... The data type of a column defines what value the column can hold: integer, character, money, date and time, binary, and so on. Each column in a database table is required to have a name and a data type.
Top answer
1 of 3
15

(If you are using SQL Server 2012 or newer, please see @wBob's answer for a cleaner approach. The approach outlined in my answer below is only required if you are using SQL Server 2008 R2 or older.)

You don't need (or want) the thousands' separator when converting to NUMERIC, regardless if it is comma, period, or space, so just get rid of them first. Then convert the comma into a period / decimal and you are done:

SELECT CONVERT(NUMERIC(10, 2), 
               REPLACE(
                       REPLACE('7.000,45', '.', ''),
                       ',', '.'
                      )
              ) AS [Converted];

Returns:

7000.45

For the sake of completeness, I should mention that I also tried:

  • SET LANGUAGE Greek;

  • Looking at various format styles for CONVERT, but nothing applies here.

  • The FORMAT function, but the input type must be a numeric or date/time/datetime value (that and it was introduced in SQL Server 2012, so not applicable to SQL Server 2008 R2 or older).

And nothing else seemed to work. I was hoping to find something more elegant than two REPLACE calls, but so far no such luck.


Also, just to mention, while not a pure T-SQL solution, this can also be accomplished via SQLCLR. And, there is a pre-done function that does this in the SQL# library (that I wrote) named String_TryParseToDecimal. This function is available in the Free version, and works in every version of SQL Server starting with SQL Server 2005:

SELECT SQL#.String_TryParseToDecimal('7.000,45', 'el-GR');

Returns:

7000.45000000000000000000
2 of 3
14

What version of SQL Server are you using? From SQL Server 2012 onwards you can use TRY_PARSE with its USING culture argument. You can also use PARSE, the difference being PARSE will fail if the conversion fails and TRY_PARSE will return a NULL, eg

DECLARE @t TABLE ( x VARCHAR(10) )

INSERT INTO @t
VALUES ( '7.000,45' ), ( 'xxx' )

SELECT x, 
    TRY_PARSE( x AS NUMERIC(10,2) USING 'El-GR' ) x
FROM @t

HTH

Find elsewhere
Top answer
1 of 5
91
SELECT height/10.0 AS HeightDecimal FROM dbo.whatever;

If you want a specific precision scale, then say so:

SELECT CONVERT(DECIMAL(16,4), height/10.0) AS HeightDecimal
  FROM dbo.whatever;
2 of 5
25
SELECT CAST(height AS DECIMAL(18,0)) / 10

Edit: How this works under the hood?

The result type is the same as the type of both arguments, or, if they are different, it is determined by the data type precedence table. You can therefore cast either argument to something non-integral.

Now DECIMAL(18,0), or you could equivalently write just DECIMAL, is still a kind of integer type, because that default scale of 0 means "no digits to the right of the decimal point". So a cast to it might in different circumstances work well for rounding to integers - the opposite of what we are trying to accomplish.

However, DECIMALs have their own rules for everything. They are generally non-integers, but always exact numerics. The result type of the DECIMAL division that we forced to occur is determined specially to be, in our case, DECIMAL(29,11). The result of the division will therefore be rounded to 11 places which is no concern for division by 10, but the rounding becomes observable when dividing by 3. You can control the amount of rounding by manipulating the scale of the left hand operand. You can also round more, but not less, by placing another ROUND or CAST operation around the whole expression.

Identical mechanics governs the simpler and nicer solution in the accepted answer:

  SELECT height / 10.0

In this case, the type of the divisor is DECIMAL(3,1) and the type of the result is DECIMAL(17,6). Try dividing by 3 and observe the difference in rounding.

If you just hate all this talk of precisions and scales, and just want SQL server to perform all calculations in good old double precision floating point arithmetics from some point on, you can force that, too:

SELECT height / CAST(10 AS FLOAT(53))

or equivalently just

SELECT height / CAST (10 AS FLOAT)
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-query-to-remove-decimal-values
SQL Query to Remove Decimal Values - GeeksforGeeks
July 23, 2025 - These functions help us manage and control the decimal precision: ... The ROUND() function in SQL is one of the most common ways to handle decimal values. This function rounds a number to the specified number of decimal places.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 207420 › how-to-convert-string-to-decimal-in-tsql
How to convert STRING to Decimal in TSQL - Microsoft Q&A
DECLARE @T TABLE ( StringData varchar(20) ); INSERT INTO @T VALUES ('995.00'), ('1,299.00'), ('1,170.00'), (NULL); SELECT StringData, TRY_CAST(REPLACE(StringData, ',', '') AS decimal(10, 2)) FROM @T; 1 comment Show comments for this answer Report ...
🌐
W3Schools
w3schools.com › sql › func_sqlserver_cast.asp
SQL Server CAST() Function
The CAST() function converts a value (of any type) into a specified datatype. Tip: Also look at the CONVERT() function. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: ...
🌐
SQLServerCentral
sqlservercentral.com › forums › topic › converting-float-to-decimal
converting float to decimal – SQLServerCentral Forums
January 31, 2008 - one sql 2000 table to a sql 2005 table. so naturally i've tried the conversions ... You said you had a float to decimal converion that errors out. Maybe you could start by posting an example of that? ... Arithmetic overflow error converting float to data type numeric.
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › functions › cast-and-convert-transact-sql
CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
SQL Server guarantees that only roundtrip conversions, in other words conversions that convert a data type from its original data type and back again, yield the same values from version to version. The following example shows such a roundtrip conversion: DECLARE @myval DECIMAL(5, 2); SET @myval = 193.57; SELECT CAST(CAST(@myval AS VARBINARY(20)) AS DECIMAL(10, 5)); -- Or, using CONVERT SELECT CONVERT(DECIMAL(10, 5), CONVERT(VARBINARY(20), @myval)); GO
🌐
Baeldung
baeldung.com › home › sql functions › how to round numbers to two decimal places in sql
How to Round Numbers to Two Decimal Places in SQL Baeldung on SQL
June 21, 2024 - Therefore, we can use TRUNCATE to round decimals places in MYSQL: SELECT TRUNCATE(scores, 2) AS rounded_scores FROM exam; rounded_scores 84.45 92.67 75.21 ... In MSSQL, since the TRUNCATE function isn’t available, we can achieve similar ...
🌐
LearnSQL.com
learnsql.com › cookbook › how-to-convert-an-integer-to-a-decimal-in-sql-server
How to Convert an Integer to a Decimal in SQL Server | LearnSQL.com
SELECT CONVERT(DECIMAL(7,2), 12) AS decimal_value; This query produces the same result as CAST(), but takes two mandatory arguments: the data type and an expression, value, or column name to convert.
🌐
PostgreSQL
postgresql.org › docs › current › datatype-numeric.html
PostgreSQL: Documentation: 18: 8.1. Numeric Types
2 weeks ago - Such a column can only hold fractional values, and it requires the number of zero digits just to the right of the decimal point to be at least the declared scale minus the declared precision. For example, a column declared as ... PostgreSQL permits the scale in a numeric type declaration to be any value in the range -1000 to 1000. However, the SQL standard requires the scale to be in the range 0 to precision.
🌐
SQL Shack
sqlshack.com › understanding-sql-decimal-data-type
Understanding the SQL Decimal data type
July 18, 2019 - Using whole numbers (by rounding decimal numbers) definitely makes one’s job easier but it often leads to inaccurate outputs, especially when we are dealing with a large number of values and crucial data. In such scenarios, it is ideal to use Sql Decimal data type in SQL Server to deliver correct results with perfect precision.
🌐
Teradata
docs.teradata.com › r › Enterprise_IntelliFlex_VMware › SQL-Data-Types-and-Literals › Data-Type-Conversions › Numeric-to-Numeric-Conversion › Usage-Notes › Using-CAST-in-Applications-With-DECIMAL-Type-Size-Restrictions
Using CAST in Applications With DECIMAL Type Size ...
Loading application · Promo placeholder · Tracking Consent Teradata.com · Developers · Getting Started · VantageCloud Lake Documentation AI Unlimited All Documentation · Downloads · Community · Teradata Community Technical Medium Blogs Github Stack Overflow · Try for free
🌐
Snowflake Documentation
docs.snowflake.com › en › sql-reference › functions › to_decimal
TO_DECIMAL , TO_NUMBER , TO_NUMERIC | Snowflake Documentation
+----------+----------------+ | COLUMN1 | CONVERT_NUMBER | |----------+----------------| | 3,741.72 | 3741.72 | +----------+----------------+ ... SELECT column1, TO_DECIMAL(column1, '$9,999.99', 6, 2) as convert_currency FROM VALUES ('$3,741.72');
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › data-types › decimal-and-numeric-transact-sql
decimal and numeric (Transact-SQL) - SQL Server | Microsoft Learn
In Transact-SQL statements, a constant with a decimal point is automatically converted into a numeric data value, using the minimum precision and scale necessary. For example, the constant 12.345 is converted into a numeric value, with a precision of 5, and a scale of 3. By default, SQL Server uses rounding when converting a number to a decimal or numeric value with a lower precision and scale.