[dba-SQLServer] Convert nvarchar to money

Nicholson, Karen knicholson at gpsx.net
Wed Feb 25 13:53:04 CST 2004


This is how you strip that stuff out:

declare @value varchar(50)
set @value = '($29.92)'
select cast(replace(replace(@value, '(', '-'), ')', '') as money)

-----Original Message-----
From: Stoker, Kenneth E [mailto:Kenneth.Stoker at pnl.gov]
Sent: Wednesday, February 25, 2004 1:24 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer] Convert nvarchar to money


This should work.  You might have to specify the size, which is 8 bytes,
and/or the precision and scale, which are 19 and 4.

INSERT INTO Table2
SELECT AcctNum, CONVERT(money, Amount)
FROM Table1

Ken Stoker
Technology Commercialization
Information Systems Administrator
PH: (509) 375-3758
FAX: (509) 375-6731
E-mail:  Kenneth.Stoker at pnl.gov 


-----Original Message-----
From: Mark Boyd [mailto:MarkBoyd at McBeeAssociates.com] 
Sent: Wednesday, February 25, 2004 10:11 AM
To: SQLServerList
Subject: [dba-SQLServer] Convert nvarchar to money


I am trying to append data from Table1 to Table2.

In Table1, the field [Amount] is datatype 'nvarchar'.

In Table2, the field [Amount] is datatype 'money'.

 

I am using the following SQL query to run the append: "INSERT INTO
Table2 SELECT AcctNum, Amount FROM Table1".

I guess I need to use the CONVERT function, but can't figure out how
this is done.

Any examples would be greatly appreciated.

 

Thanks,

Mark Boyd

Sr. Systems Analyst

McBee Associates, Inc.

 

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com



More information about the dba-SQLServer mailing list