CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: SQL Numeric conversion

  1. #1
    Join Date
    Dec 2019
    Posts
    15

    SQL Numeric conversion

    Hi,

    I have got some problems when running this SQL statement :

    select CONVERT(numeric,0x120200000000084e20e90015)

    It shows "Erreur de conversion du type de données varbinary en numeric.".

    How could I manage to fix that point ?

    Thank you for help !

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,373

    Re: SQL Numeric conversion

    Have you tried to single quote the binary string?

  3. #3
    Join Date
    Dec 2019
    Posts
    15

    Re: SQL Numeric conversion

    Quote Originally Posted by Arjay View Post
    Have you tried to single quote the binary string?
    Hi Arjay,

    Do you mean something like this : select CONVERT(numeric,'0x120200000000084e20e90015') ?

    If so, it does not work. It gives an error ==> Erreur de conversion du type de données varchar en numeric.
    Last edited by James West; October 8th, 2020 at 01:20 PM.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,819

    Re: SQL Numeric conversion

    Quote Originally Posted by James West View Post
    Hi Arjay,
    Do you mean something like this : select CONVERT(numeric,'0x120200000000084e20e90015') ?
    If so, it does not work. It gives an error ==> Erreur de conversion du type de données varchar en numeric.
    Well, but you were going to convert it to numeric, not to datetime!
    Quote Originally Posted by James West View Post
    Hi,

    I have got some problems when running this SQL statement :

    select CONVERT(numeric,0x120200000000084e20e90015)
    Weren't you?
    Victor Nijegorodov

  5. #5
    Join Date
    Dec 2019
    Posts
    15

    Re: SQL Numeric conversion

    Quote Originally Posted by VictorN View Post
    Well, but you were going to convert it to numeric, not to datetime!

    Weren't you?
    It was an error .

    I have posted two threads in this way and one is related also to date conversion.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,819

    Re: SQL Numeric conversion

    Quote Originally Posted by James West View Post
    It was an error .

    I have posted two threads in this way and one is related also to date conversion.
    So did it work with numeric?
    Victor Nijegorodov

  7. #7
    Join Date
    Sep 2020
    Posts
    13

    Re: SQL Numeric conversion

    The process of changing data type of a value into another data type is referred to as data type conversion and also almost all programing languages include some type of data converting functions or functionality. When we turn our perspective to SQL Server in order to discuss details of SQL data converting operations, at first we can separate data conversion process into two parts; implicit and explicit conversions. Implicit conversion is done by SQL Server for internal needs and you can also find additional details in the article Implicit conversion in SQL Server. Explicit conversion is performed explicitly by a database programmer or administrator and at the same time this conversion process is made with help of any data conversion function. In this article, we will particularly focus on the SQL CONVERT function. This function provides a means to convert one data type to another specified data type. At first, we will interpret the syntax of the SQL CONVERT function.

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,819

    Re: SQL Numeric conversion

    Quote Originally Posted by mikeduke1290 View Post
    The process of changing data type of a value into another data type is referred to as data type conversion and also almost all programing languages include some type of data converting functions or functionality.
    ...
    At first, we will interpret the syntax of the SQL CONVERT function.
    Is this quotation from https://www.sqlshack.com/sql-convert-function/ ?
    Or what were you going to say?
    Victor Nijegorodov

  9. #9
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,287

    Re: SQL Numeric conversion

    Quote Originally Posted by VictorN View Post
    Is this quotation from https://www.sqlshack.com/sql-convert-function/ ?
    Or what were you going to say?
    I'd say it's a copy-and-paste hijack!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.7.6)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)