example using cast or convert?

example using cast or convert?

 

  

Howdy -

I'm trying to find correct syntax to convert a text column to
numeric. I've tried examples like so -


[snip examples]

select convert(numeric, ccfccard) from emp0
where ccfccard between '10980000002' and '10990000000'

**error: Server: Msg 529, Level 16, State 2, Line 1
Explicit conversion from data type text to numeric is not allowed.

- also -

select convert(numeric, convert(varchar (50), ccfccard)) from emp0
where ccfccard between '10980000002' and '10990000000'

**error: Server: Msg 306, Level 16, State 1, Line 1
The text, ntext, and image data types cannot be compared or sorted,
except when using IS NULL or LIKE operator.

[/snip examples]


There was one attempt where I was able to get something like 'can't
convert
directly from text' (sorry, I forgot to copy the error message).

Can someone send me a doc to give examples of how to convert or cast
text fields into numeric format *without* having to change the database
/ field?

Thanks!

-X


MS Sql Server LazyDBA home page