insert varchar data into a float column.

Posted on 2006-05-18
Last Modified: 2012-08-14

how can i insert varchar (that holds numeric values e.g 200) data  from one table into a float column in another table?

Question by:JakeyCakes
    LVL 142

    Accepted Solution

    note AGAIN that you should NOT use float data type if not really necessary.
    decimal/numeric  or int/bigint are in most cases better suited and avoid some problems.


    insert into table2 (float_field) select cast( varchar_field as float ) from table1
    LVL 75

    Assisted Solution

    by:Aneesh Retnakaran
    Do we really need casting here, the sql server will use implicit conversion

    for example

    declare @float float
    declare @varchar varchar(32)

    set @varchar = '12.222'
    set @float = @varchar

    select @float

    so your query

    insert into table2 (float_field) select  varchar_field  from table1

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now