Exercise #3 |
||
|
Find the model number, RAM and screen size of the laptops with prices over $1000. There is another quite easy task. However there is one mistake of instructive value. Here is the solution which contains this mistake: String constants in statements instructions are quoted in single quotes. The constants of numeric types are given without quotation marks. Thus the last predicate should have been written as price > 1000. However there is one peculiarity connected with implicit transformation of the types. You can read about it in detail in Chapter 5 (item 5.9). It should be also noted here that Disallowed implicit conversion from data type varchar to data type money One should take note that if the price column were of any other digital type, i.e.,float, then the implicit conversion would be made, and there would be no error. Of course one can make explicit conversion of this type; this is a quite legitimate version of this query:
Now, if you run the query, which generated error, then it will produce the resulting set and not the aforementioned error message. The matter is that SQL Server 2005, which is currently used on the site, this strange difference in behaviour of money data type from other digital types with respect to implicit conversion is already eliminated. Thus, you will obtain the correct result when using the implicit conversion of the data type. The only point is that there is no use to make the server waste its resources for it, if one can do without conversion of the data types? |
||


