Results 1 to 4 of 4

Thread: Var to Int

  1. #1
    Join Date
    Jun 2006
    Location
    DC
    Posts
    123

    Unanswered: Var to Int

    Hey guys what would be the best way to update a column from a varchar to an int...... when the values are like so 61114.7016601563

    what would be my best method to get .... 4 digit precision after the decimal.....

    when converting to a decimal(5,2) i receive an arithmetic overflow...etc...

    Server: Msg 245, Level 16, State 1, Line 1
    Syntax error converting the varchar value '63737.1474609375' to a column of data type int.

    Server: Msg 8115, Level 16, State 8, Line 1
    Arithmetic overflow error converting numeric to data type numeric.

    any suggestions would be greatly appreciated...

    thanks,
    Jonathan

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    DECLARE @xxx table (Col1 varchar(50), Col2 decimal(15,4))
    
    INSERT INTO @xxx(Col1)
    SELECT '61114.7016601563' UNION ALL
    SELECT '9/11/2001' UNION ALL
    SELECT 'xxx'
    
    SELECT * FROM @xxx
    
    UPDATE @xxx SET Col2 = CONVERT(decimal(15,4),Col1)
    WHERE ISNUMERIC(Col1) = 1
    
    SELECT * FROM @xxx
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jun 2006
    Location
    DC
    Posts
    123
    Brett,
    Much appreciated... but im still getting the same error when replacing those values...

    Server: Msg 8115, Level 16, State 8, Line 10
    Arithmetic overflow error converting numeric to data type numeric.
    The statement has been terminated.

  4. #4
    Join Date
    Jun 2006
    Location
    DC
    Posts
    123
    my apologies brett...works like a charm. .thanks a lot....

Posting Permissions

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