Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to remove comma and convert in to INT Expand / Collapse
Author
Message
Posted Monday, June 17, 2013 4:40 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, May 9, 2014 7:21 AM
Points: 98, Visits: 251
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
Post #1464068
Posted Monday, June 17, 2013 4:57 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 4:32 AM
Points: 2,651, Visits: 4,731
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/
Post #1464077
Posted Monday, June 17, 2013 5:12 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, May 9, 2014 7:21 AM
Points: 98, Visits: 251
Thanks Sir..
Its worked thanks for your help :)
Post #1464086
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse