Hi all, it's my first post in this forum, correct me if I do something incorrect.
I just want to discuss this question from the performance point of view, so don't worry about the design or other stuff.
I have read through many threads and articles, it seems that no one has explained my concern.
If we replace the implicit conversion by explicit conversion, does it help for the performance?
For example, I created the following table
CREATE TABLE student (s_id tinyint, name varchar(20)); INSERT INTO student VALUES (1,'name1'),(2,'name2'),(3,'name3')
Does the following two queries make any difference from the performance point of view? As you can see, the first one applies implicit conversion, whereas the second one applies explicit conversion
SELECT * FROM student WHERE s_id = '2';
SELECT * FROM student WHERE s_id = CAST('2' AS tinyint);
I understand that I should query using WHERE s_id = 2, but I just want to make this as a example to understand the difference between implicit and explicit conversion.
Another related question is when I insert the records, is it better if I Cast the number to tinyint as follows?
INSERT INTO student VALUES (CAST(4 AS tinyint),'name4')
Thanks guys