Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Conversion failed when converting the varchar value to data type int.

$
0
0

Hi,

I am building a View with an integer column by filtering data from Master table and below is the sample script. And Select Query on the View with WHERE condition is throwing the following exception.

Msg 245, Level 16, State 1, Line 1

Conversion failed when converting the varchar value 'ABCDEF' to data type int.

----------------------Creating Table----------------------------------

Create table MasterEmployees (EmpIDvarchar(50))

Insert intoMasterEmployeesvalues('12345'),('ABCDEF')

----------------Creating the view ------------------------

Create viewChildEmployees

AS

Select Cast(EmpiDas bigint)asEmpIDfromMasterEmployeeswhereISNUMERIC(EmpID)=1

---------------------------Issue ----------------------------

Executing Select query on View without WHERE condition is working fine.

Adding WHERE condition to the Query like below

Select *fromChildEmployeeswhereEmpid= is throwing below exception 

-------------------------Exception Message-----------------------

Msg 245, Level 16, State 1, Line 1

Conversion failed when converting the varchar value 'ABCDEF' to data type int.

Please help


 

 

 




 




Mohan







Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>