Implicit Conversion

  • Pulivarthi Sasidhar

    SSCertifiable

    Points: 6706

    Comments posted to this topic are about the item Implicit Conversion

  • lee.south

    SSC-Addicted

    Points: 423

    Does it? Not 2 rows 1 and 2?

    Sorry, of course it does, looking at the second sample not the first...

  • RossOverThere

    SSC Veteran

    Points: 293

    Interesting. The subtle difference between the two code samples provided makes all the difference on this one.

  • Ed Wagner

    SSC Guru

    Points: 286960

    A simple one to start the week and get my brain going again is appreciated. Thanks.

  • Kaye Cahs

    SSCarpal Tunnel

    Points: 4135

    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.

  • Tom_Hogan

    Hall of Fame

    Points: 3494

    Should have paid more attention to the QotD title.

  • djj

    SSCoach

    Points: 18738

    Nice. I let the table def blind me to the facts. 😀

  • archie flockhart

    SSCrazy

    Points: 2339

    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.

  • Zagyg

    SSCommitted

    Points: 1949

    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.

  • archie flockhart

    SSCrazy

    Points: 2339

    Yes you're right - which makes it a better and subtler question than I had thought.

  • Revenant

    SSC-Forever

    Points: 42467

    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!

  • Zagyg

    SSCommitted

    Points: 1949

    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:

  • Anand BI Developer

    SSCommitted

    Points: 1772

    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 13 (of 13 total)

You must be logged in to reply to this topic. Login to reply