Wednesday, December 7, 2011

Implicit conversions , sometimes it is hidden

Consider simple table with one column defined as REAL datatype
CREATE TABLE #t (c REAL)
INSERT INTO #t VALUES (0)

SELECT COUNT(*) FROM #t WHERE c=''

In above statement you expect getting 0 rows to be returns as we filter out for all nonempty rows..But it returns 1 and the answer you find looking at execution plan.




SQL Server will implicitly convert '' to REAL datatype with 0 and a result is 1 row to be return.

2 comments:

ben said...

Thank you so much for everything you do.
Emergency Dentist London

Susan said...

A huge collection of all the celebrity net worths of the world. How much is celebrity worth? Compare yourself to your favorite celebrity. A huge collection of all the Celebrity net worth of the world. How much is celebrity worth? Compare yourself to your favorite celebrity.