JGH5
asked on
Need to update several columns and tables in a database and convert scientific notation to a decimal(27,17).
Need to update several columns and tables in a database and convert scientific notation to a decimal(27,17).
Using the following for COLUMN(S) for the scientific notation part:
CASE
WHEN COLUMN like '%E-%' THEN LTRIM(RTRIM(CAST(CAST(COLU MN AS FLOAT) AS DECIMAL(18,18))))
WHEN COLUMN like '%E+%' THEN NULL
ELSE COLUMN
END
What is the best way to update existing columns? SS 2008 R2
Using the following for COLUMN(S) for the scientific notation part:
CASE
WHEN COLUMN like '%E-%' THEN LTRIM(RTRIM(CAST(CAST(COLU
WHEN COLUMN like '%E+%' THEN NULL
ELSE COLUMN
END
What is the best way to update existing columns? SS 2008 R2
Why are you NULLing out "E+" values?
Why not just something like:
CASE
WHEN COLUMN like '%E%' THEN CAST(CAST(COLUMN AS FLOAT) AS DECIMAL(18,18))
ELSE COLUMN
END
Why not just something like:
CASE
WHEN COLUMN like '%E%' THEN CAST(CAST(COLUMN AS FLOAT) AS DECIMAL(18,18))
ELSE COLUMN
END
ASKER
Also, the data is already in the table as a varchar and needs to be converted to a decimal data type.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window