RE: example using cast or convert?

RE: example using cast or convert?

 

  


--Thanks for the reply -

--I got the message:

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

--and now that I got that error, I kinda recall that SQL Server won't
--like this. Gonna try something new.

--Thanks again!

-X




-----Original Message-----




I haven't used CONVERT for much except date formatting changes. If I
were trying to do this, I would use CAST. For example:

Cast(ccfccard as numeric)

You have to be sure that the text that you are giving can fit in the
numeric data type.

HTH

-----Original Message-----


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



---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
Website : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: mssqldba-[Email address protected]




MS Sql Server LazyDBA home page