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 |
|
Trininole
Yak Posting Veteran
83 Posts |
Posted - 2010-05-25 : 16:45:49
|
| what is the syntax to convert a varchar datatype to numeric in a join statement?Roger DeFour |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-25 : 17:06:07
|
| convert(<numeric data type>,varchar_field) |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-05-26 : 03:53:43
|
quote: Originally posted by vijayisonly convert(<numeric data type>,varchar_field)
SELECT CONVERT(INT, CASE WHEN ISNUMERIC(<varchar column>) = 1 THEN <varchar column> ELSE NULL ) FROM YourTableyou can use IsNumeric to avoid error while conversion for unexpected wrong data.Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-26 : 04:03:19
|
quote: Originally posted by vaibhavktiwari83
quote: Originally posted by vijayisonly convert(<numeric data type>,varchar_field)
SELECT CONVERT(INT, CASE WHEN ISNUMERIC(<varchar column>) = 1 THEN <varchar column> ELSE NULL ) FROM YourTableyou can use IsNumeric to avoid error while conversion for unexpected wrong data.Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER
Note that isnumeric is not reliablehttp://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/enhanced-isnumeric-function.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|