SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to remove comma and convert in to INT


How to remove comma and convert in to INT

Author
Message
kiran.rajenimbalkar
kiran.rajenimbalkar
SSC-Addicted
SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)

Group: General Forum Members
Points: 445 Visits: 331
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
Kingston Dhasian
Kingston Dhasian
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6197 Visits: 5291
There are 2 ways to do this

SELECT   CONVERT(NUMERIC(17,2),REPLACE(REPLACE(data,',',''),'$',''))
FROM dataconvert

SELECT CONVERT(MONEY,REPLACE(data,',',''))
FROM dataconvert




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/
kiran.rajenimbalkar
kiran.rajenimbalkar
SSC-Addicted
SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)

Group: General Forum Members
Points: 445 Visits: 331
Thanks Sir..
Its worked thanks for your help Smile
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search