May 30, 2016 at 9:28 pm
Comments posted to this topic are about the item Implicit Conversion
May 31, 2016 at 2:27 am
Does it? Not 2 rows 1 and 2?
Sorry, of course it does, looking at the second sample not the first...
May 31, 2016 at 2:49 am
Interesting. The subtle difference between the two code samples provided makes all the difference on this one.
May 31, 2016 at 5:22 am
A simple one to start the week and get my brain going again is appreciated. Thanks.
May 31, 2016 at 6:53 am
This one wasn't simple for me. It takes a keen eye and some focused thought to get it right. I failed.
Thanks for the good question.
May 31, 2016 at 6:58 am
Should have paid more attention to the QotD title.
May 31, 2016 at 7:36 am
Nice. I let the table def blind me to the facts. 😀
May 31, 2016 at 9:12 am
Without necessarily knowing anything about the conversions involved, you can see that the data being added comes from a single INSERT statement, where the input data is the union of three result sets each containing one distinct row .
Either the INSERT statement succeeds and inserts three rows, or fails with an error and inserts none.
But 3 is not offered as a possible answer, so it must cause an error and insert no rows.
May 31, 2016 at 10:01 am
archie flockhart (5/31/2016)
Without necessarily knowing anything about the conversions involved, you can see that the data being added comes from a single INSERT statement, where the input data is the union of three result sets each containing one distinct row .Either the INSERT statement succeeds and inserts three rows, or fails with an error and inserts none.
But 3 is not offered as a possible answer, so it must cause an error and insert no rows.
Except that the select at the bottom is DISTINCT ID, and the script inserts ID 1 once and ID 2 twice. So if the conversion worked, the correct answer would still be 2 not 3.
May 31, 2016 at 10:07 am
Yes you're right - which makes it a better and subtler question than I had thought.
May 31, 2016 at 12:24 pm
archie flockhart (5/31/2016)
Yes you're right - which makes it a better and subtler question than I had thought.
+ 1
Thank you, Sasidhar!
June 1, 2016 at 8:42 am
archie flockhart (5/31/2016)
Yes you're right - which makes it a better and subtler question than I had thought.
Indeed. It made me fixate on this point and select 2 as the answer - wrong!! :crazy:
June 27, 2016 at 6:27 am
conversion type errors are display ..,
Actually in third part they give value 456
but if we give out put as varchar type '456' mean error wont showing.
eg:
DECLARE @tbl TABLE ( id INT, Name VARCHAR(5) );
INSERT INTO @tbl
SELECT
1 AS Id
, 'ABC' AS Alphabets
UNION
SELECT
2
, 'XYZ'
UNION
SELECT
2
, '456';
SELECT DISTINCT
id
FROM
@tbl;
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply