Error converting data type varchar to int
When inserting or updating data into a table the error will as "Error converting data type varchar to int". As the name indicates this error is comming because the programmer have a field which is integer and while querying he passes any data which is not convertable to int
Solutions
The first and best solution is to make sure that the data passing to sql server is copatible with datatype. ie if passing a string to an int field it should be convertible to integer say '0','222' etc
And if trying to copy data from one table to another there is chance to fire this error if either the column mapping is not correct or theire is null in the source field
If theire is null in the source field use isnull function. See the following query
INSERT INTO SrcTbl(id)SELECT ISNULL(id,0) FROM destTBL
HAPPY PROGRAMMING
No comments:
Post a Comment