Char to PLU_NUM(float)

  • Hi,

    I have 2 tables to join on a common field(column) having char and PLU_NUM(float) values..They have values like ..298748372690 (all numbers)

    I cant edit the table with PLU_NUM(float) but can change the other table having values in char.

    So i need to change all char values to PLU_NUM(float)..

    How is it possible.

    Thanks.

    Regards,

    Sushant

    DBA

    West Indies

    Regards
    Sushant Kumar
    MCTS,MCP

  • Sushant

    What is PLU_NUM(float)? Do you just mean float? If you need to compare numbers in a character column with numbers in a numerical column, you will need to CAST one of them to the other's data type. Try it both ways round and see which gives the better performance.

    John

  • I think PLU_NUM(float) its float values in sql 2000..

    Doesn't CAST convert only 1 value not all the values in a table?

    Regards,

    Sushant

    Regards
    Sushant Kumar
    MCTS,MCP

  • Is PLU_NUM a udf in your system?

    Cast does not change the stored value of any data (unless you using it in an update statement). Perhaps if you could provide some level of details about what you are doing we can help.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Hi,

    I changed the data types successfully..

    I used

    SELECT CAST(mycolname AS float) FROM tablename

    SELECT CONVERT(FLOAT, mycolname) FROM tablename

    After running above statments,

    I still got same error "it cannot convert varchar to float" but that it stopped after showing some results

    so i saw that the next column values wich it cannot do were like '344723-547'

    so i removed '-' from the values

    and then again i ran CAST and CONVERT and

    then when i went into table name right click design, i would change it to float. 🙂

    Thanks

    Regards,

    Sushant

    Regards
    Sushant Kumar
    MCTS,MCP

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply