About 287,000 results
Open links in new tab
  1. Convert a string to int using sql query - Stack Overflow

    Jan 10, 2013 · Definitely not the right answer for the original question since it was in relation to SQL Server 2005, but since it is 2019 and fewer folks are strapped to such an old version of SQL Server, this answer is definitely helpful.

  2. How to convert or cast int to string in SQL Server

    May 8, 2019 · To convert the type of the column you have to migrate the schema of this table. To convert the values in the cells of this column you have to migrate the data. Look into the documentation if the ORM you are using to find out how both migrations have to look like in …

  3. How do I convert (or cast) a String value to an Integer value?

    Aug 27, 2017 · Apache Spark's SQL has partial compatibility with Apache Hive. So, most SQL that can be written in Hive can be written in Spark SQL. Detail: To convert a STRING to a specific numeric type like INT, a cast may be used. The cast consists of wrapping the target with parenthesis and preceding the parenthesis with the type to which it is to be changed.

  4. sql - TSQL - Cast string to integer or return default value - Stack ...

    Feb 11, 2013 · As Joseph Mentions, users of SQL 2012+ should use TRY_CONVERT/TRY_CAST, which are explicitly intended to resolve the OP's question. This answer was written before SQL 2012 was released. …

  5. SQL order string as number - Stack Overflow

    Aug 9, 2010 · Another way to convert. If you have string field, you can transform it or its numerical part the following way: add leading zeros to make all integer strings having equal length. ORDER BY CONCAT( REPEAT( "0", 18 - LENGTH( stringfield ) ) , stringfield ) or order by part of a field something like 'tensymbols13', 'tensymbols1222' etc.

  6. ORACLE - String to number - Stack Overflow

    Oct 25, 2012 · SELECT TO_NUMBER('123,456.78', '999,999.990') FROM DUAL; ...gives a result of 123456.78. (Tested in SQL*Plus and SQL Developer.) This shows that TO_NUMBER is just creating a pure number and it's not using the format code to display that number. If it were, the result displayed would include a comma and a trailing zero.

  7. sql - how to convert this String to Decimal - Stack Overflow

    Nov 15, 2017 · i have this String '5666,232343' and i want to convert it to Decimal, i use cast('5666,232343' as decimal(7,5)) but it returns NULL value. Do you know why it doesn't work with CAST

  8. How to convert a string to number in PL/SQL - Stack Overflow

    create or replace function is_int(p_str in varchar2) return number as begin if regexp_instr(p_str, '^[[:space:]]*[[:digit:]]{1,5}[[:space:]]*$') > 0 then return 1; end if; return 0; end; / show errors with strings as ( select '12345' as string from dual union all select '1234' as string from dual union all select '123' as string from dual union all select '12' as string from dual union all ...

  9. sql - VARCHAR to DECIMAL - Stack Overflow

    Jun 19, 2012 · From MSDN: "Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number. For example, the number 123.45 has a precision of 5 and a scale of 2." If you specify (10, 4), that means you can only store 6 digits to the left of the decimal, or a max number of 999999.9999.

  10. How do I format a number with commas in T-SQL?

    Dec 7, 2010 · To strip the ".00" off the end of your number string, parsename is super-handy. It tokenizes period-delimited strings and returns the specified element, starting with the rightmost token as element 1. SELECT PARSENAME(CONVERT(varchar, CAST(987654321 AS money), 1), 2) Yields "987,654,321"

Refresh