Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2008-05-01 : 06:59:27
|
| Hi i've a staging table were i have datatypes of nchar.I'd like to convert these to money datatypeAm trying to do this like this but the data return is not correct there is aslo null and blank rows so i must account for them also.select cast(IsNumeric((Value2)) as money)from tbl_Sales |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2008-05-01 : 07:44:04
|
quote: the data return is not correct
What's wrong with it?Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-01 : 07:45:31
|
| select case when IsNumeric(Value2) =1 then cast(Value2) as money else 0 endfrom tbl_Saleshowever you should be careful using IsNumeric function http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/enhanced-isnumeric-function.aspx |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
|
|
ganeshkumar08
Posting Yak Master
187 Posts |
Posted - 2008-05-02 : 04:53:56
|
| Helloselect case when IsNumeric('3.5') =1 then cast('3.5' as money) else 0 endTry this Ganesh |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-02 : 04:56:19
|
quote: Originally posted by ganeshkumar08 Helloselect case when IsNumeric('3.5') =1 then cast('3.5' as money) else 0 endTry this Ganesh
Have you reffered the links which i & Ryan posted on ISNUMERIC? |
 |
|
|
ganeshkumar08
Posting Yak Master
187 Posts |
Posted - 2008-05-02 : 05:13:16
|
| Yes, now only i reffered, now i got it |
 |
|
|
|
|
|