SQL Server: Error converting data type varchar to numeric.

Convert varchar to decimal error 1

  • Add another column with required dataType.
    [sql]
    ALTER TABLE [table name]
    ADD [column name] decimal(10,2) NULL
    [/sql]
  • Import all data from old column to new column with dataType check.
    [sql]
    update [table name]
    set [column name] = cast([old column name] as decimal(10,2))
    where [old column name] <> ”
    [/sql]
  • Delete / drop old column with the help of query / management studio once you imported all your required data.
  • Rename your new column as per requirement.

Convert varchar to decimal error 2

It may be because alphabet character exist
[sql]
select * from TABLE where ID = 4267364 and SOME_VALUE NOT LIKE ‘%[a-z]%’
[/sql]

Be the first to comment

Leave a Reply

Your email address will not be published.


*