Thursday, 9 August 2012

Conversion failed when converting the nvarchar value 'GENERAL' to data type int.

SQL Server Error :


Causes : 

       -       It causes when you are executing query in SQL Server 2008 /2005 or ..
   
       -       Here it may cause because of your query execution or datatype of entity.

       -       Ex :  Converting from int to string  or input int but datatype is nvarchar etc


Actions :

      -       Suppose your data stored in varchar format , then you should use   ' '   single quotationmark for parameters in where conditions.

      Example :


 Datatype  name nvarchar(50)

1)  Wrong Query :- >    

SELECT [emp_no]  from  [emp_MAST] where [shift_cd] = 1;

Here shift_cd  = 1 (which is int) bt my ticketNo is nvarchar(50) .
So error .


2)   Correct query  :- >    

SELECT [emp_no]  from  [emp_MAST] where [shift_cd] = '1';


This is will help you !!



No comments:

Post a Comment