Wednesday 2 April 2014

Data Mismatch on WHERE Clause : will cause performance issue?

Yes.Mismatch in data type on where clause will cause performance problem.
                   Any datatype mismatch on WHERE clause might cause serious performance problems.Predicates on both sides of comparisons (for example on WHERE clause) always must match datatypes. It means that if the left side of predicate is integer than the right side needs to be integer. If the datatypes are different then SQL Server tries to make and implicit conversion to match the datatypes of both sides like below example.
If an implicit conversion is not possible SQL Server returns an error like below.

When an implicit conversion is possible, SQL Server automatically converts the data from one data type to another. Selection of the conversion direction depends on data loss possibility. SQL server choose the side which is to avoid data lost. For example, when a smallint is compared to an int, the smallint is implicitly converted to int before the comparison proceeds.



No comments:

Post a Comment

First Database In Sql Server