[dba-SQLServer]Convert Varchar(50) to Money

Nicholson, Karen knicholson at gpsx.net
Thu Nov 6 14:17:03 CST 2003


I know it should have been done on the application level.  This is a canned
system, and people use the udf fields in the database as they need them. All
udf fields are varchar(50) so I keep getting rheemed on these... thank you
for the solution.

-----Original Message-----
From: Billy Pang [mailto:tuxedo_man at hotmail.com]
Sent: Thursday, November 06, 2003 1:06 PM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer]Convert Varchar(50) to Money


Number formatting should be done on the application level.
but if you must, here it is...

DECLARE @the_value VARCHAR(50)

SET @the_value = '30'

PRINT '$' + CAST(CAST(@the_value AS decimal(9,2)) AS VARCHAR(10))

HTH
Billy


>From: "Nicholson, Karen" <knicholson at gpsx.net>
>Reply-To: dba-sqlserver at databaseadvisors.com
>To: "Dba-Sqlserver (E-mail)" <dba-sqlserver at databaseadvisors.com>
>Subject: [dba-SQLServer]Convert Varchar(50) to Money
>Date: Thu, 6 Nov 2003 12:14:13 -0500
>
>I need to convert a field that is a varchar(50) to money.  The data looks
>like this: $29.95 or ($29.95).
>
>Any ideas?
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

_______________________________________________
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