How to remove comma and convert in to INT

  • Hi,

    How to remove comma and how to convert this column into [numeric](17, 2) this formate.

    I have conevrt my this column values in this format [numeric](17, 2) NULL now this column have nvarchar datatype in my source.

    Please sugget

    drop table dataconvert

    go

    create table dataconvert

    (data nvarchar(15))

    insert into dataconvert values('$0')

    insert into dataconvert values('$40,000')

    insert into dataconvert values('$2,350')

    Regards,

    KRaj

  • There are 2 ways to do this

    SELECTCONVERT(NUMERIC(17,2),REPLACE(REPLACE(data,',',''),'$',''))

    FROMdataconvert

    SELECTCONVERT(MONEY,REPLACE(data,',',''))

    FROMdataconvert


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Thanks Sir..

    Its worked thanks for your help 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

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