score:3
if Phone_Number has any alphabetic or symbol characters it will fail when CASTing it to DECIMAL:
Update table set Test = Convert(varchar(53), Cast(Phone_Number as Decimal))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Your question is very vague, but you could try:
Update YourTable
SET Test=CASE
WHEN ISNUMERIC(Phone_Number)=1 THEN Convert(varchar(53), Cast(Phone_Number as Decimal)) --this is your code unchanged
ELSE Phone_Number
END
...
More questions
- SQL Server : error converting data type varchar to numeric
- Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to numeric
- Empty XML node causes Error converting data type varchar to numeric
- Error converting data type varchar to numeric. When try to compare numeric
- Error converting data type varchar to numeric
- Error converting data type varchar to numeric with substring conversion
- Arithmatic overflow error converting varchar to data type numeric (SQL)
- SQL Server 2012 Error converting data type varchar to numeric
- Error converting data type varchar to numeric - but with numeric value
- Error converting data type varchar to numeric when using CASE
- Error converting data type varchar to numeric in SQL
- Error converting data type varchar to numeric in table with different data types
- SQL - Error converting data type varchar to numeric
- In Trigger getting error as error converting data type varchar to numeric
- SQL : Error converting data type varchar to numeric
- Error converting data type varchar to numeric in sql when value is compared in where clause
- Error converting data type varchar to numeric using a case function
- Error converting data type varchar to numeric when filtered by a clustered indexed column
- Error converting data type from varchar to numeric
- Arithmetic overflow error converting varchar to data type numeric in SQL Server
- SQL Server : error converting data type varchar to numeric unless I use REPLACE
- SQL Server: Case statement is displaying Msg 8115, Arithmetic overflow error converting varchar to data type numeric
- Arithmetic overflow error converting numeric to data type varchar
- SQL Error converting data type varchar to numeric
- Error converting data type varchar to numeric using cast
- Error converting data type varchar to numeric VB.Net(Windows Service)?
- Arithmetic overflow error converting varchar to data type numeric -VBA
- An arithmetic overflow error occurred while converting varchar to numeric data type in SQL Server 2008
- SQL Server: Error converting data type nvarchar to numeric
- Sql query, selecting on unique identifier gives - Error converting data type varchar to uniqueidentifier
More questions with similar tag
- SQL: Concatenate two DATEPART functions
- clicking on link button in gridview does not show the details in detailsview
- Microsoft DTC not playing nice with a transaction in a sproc
- SSRS - Need to hide column inside a group
- Conditional aggregation in a window function: gaps and island problem
- Build a SQL query with a DateTime parameter
- Prioritizing I/O for a specific query request in SQL server
- No output from SQL Server 2005 T-SQL and PDO when using SET
- SQL Server: rows to columns
- T-SQL dynamic sql within while loop
- Sql Server 2012 cal licence model
- Conditional Join possible in SQL Server 2005?
- Joining one particular table causes high logical reads
- Extracting Username\password from text\properties file in VBScript
- How to Apply Conditional Logic to Where Statement
- FK referencing PK with same column
- Rounding within avg() over () clause not working - SQL Server
- How to filter SQL query by using SSRS Yes or No Parameter
- SQL Join from 2 Tables with Null Values
- How to make SET XACT_ABORT ON rollback the transaction?
- SQL Server 2008 - Removing schema ownership
- How do I copy SQL Server 2012 database to localdb instance?
- Formatting datetime values returned in a SELECT..FOR XML statement
- SQL SERVER - Set variable in WHERE clause
- How to use IN condition in SQL Server when comparing Varchars with trailing spaces?
- SQL Server - Setting Multiple Values in a Case Statement?
- How to use trim in select query rails or in sql query
- Transpose group of rows into multiple columns
- OPENJSON() SQL SERVER is returning null when the path is correct
- How to get remaining percentages for column?
Source:
stackoverflow.com