Question

I am having to change one of the columns in table which currently is Float to Varchar, but when I use alter command, it stores some of the longer numbers in Scientific Notation.

Can I avoid this?

If not, is there a way to easily update the table later to store the scientific notation as normal integer?

Thanks

Was it helpful?

OTHER TIPS

I have a workaround for this I have used in the past. Dan isn't far off, but just casting it won't work. You can alter the table by adding a new varchar column then using str and ltrim to update the new column from the old float column. Say your varchar column was varchar(50), use something like:

update YourTable set NewColumn = ltrim(str(OldColumn, 50))

str() converts to character data, ltrim() gets rid of any extra blanks on the left. You can then always get rid of the old column. Feels janky but should work for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top