SELECT INTO

  • paul.knibbs (6/14/2010)


    I said it would return zero thanks to the cropped NULL, but even without that, surely it would return 4 rows, not 3? I would expect the values from Table 1 to be duplicated twice in Table 2 with an attached Identity column...or am I missing something?

    The question asked about the number of columns returned, not the number of rows. The number of rows would be 2, by the way. There is no duplication, every row in #Table_1 gets inserted once in #Table_2.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Oops! Make note to self: try answering the actual question asked rather than the one I made up in my head... :ermm:

  • Lost... Still learning to READ the question carefully.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • I'm siding with the pedants on this one. I knew what was intended (and what the correct answer would be) but picked the error anyway, because that's how the question is presented. If you're going to be a pain the a** and use a graphic, at least do it properly.

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • ronmoses (6/14/2010)


    I'm siding with the pedants on this one. I knew what was intended (and what the correct answer would be) but picked the error anyway, because that's how the question is presented. If you're going to be a pain the a** and use a graphic, at least do it properly.

    A little off topic, but I'm going to ask it anyway - why do you equate using a graphic to being a pain in the ***?

    Edit: Those stars are not my doing. Apparently, this site adheres to the hypocritical notion that the synonym of donkey should be cennsored, even when used in an expression that is widely known and that is used by virtuallly everyone on a daily basis. I was not aware that this site targets an under-13 audience, but I'll keep it in mind in my future posts.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • <whining>

    Got it wrong because of the syntax error. Last week, I got the QoD wrong because I fixed a syntax error that I shouldn't have fixed. The question last week did not have "syntax error" as an option. This one did, so I picked it. Just not sure when to fix those syntax errors and when not to...

    <\whining>

    Cindy

  • Finally an easy question!:-D Thank you very much!

  • UMG Developer (6/13/2010)


    I got it wrong because I didn't read the question correctly, I thought it was asking how many rows where returned.

    Somwhere within my neuron subsystem, I noticed the word "columns" instead of "rows," but my clicking finger didn't get the message and nevertheless clicked on 2 instead of 3 :-).

  • I didn't even notice the graphic, and apologies. I'll clean that up and reshoot an image.

    Hugo, we have had numerous complaints on profanity at times, so we've set a few words to black out. In terms of a professional environment, most people, I think, wouldn't talk like that with their boss, so I'll accept their complaints here. However, if we allowed that language, I'm more concerned there are plenty of people that wouldn't be able to restrain themselves and we'd have it written in every other post. Maybe every other word.

  • I think it is a good question, thank you. I had to read up on the identity and select into before making my choice so I learned something and got it right to boot!

    In the future, please refrain from using a graphic for code as it just wastes unnecessary time retyping when it could have been copied and pasted instead. Remember this is about learning, and often times running the code before/after is part of that process so try not to inhibit such behavior.

  • Steve Jones - Editor (6/14/2010)


    if we allowed that language, I'm more concerned there are plenty of people that wouldn't be able to restrain themselves and we'd have it written in every other post. Maybe every other word.

    Are we really that immature in this community of professionals? Well, I'll take your word for it, you've been running this site long enough that you should know!

    Bradley Deem (6/14/2010)


    In the future, please refrain from using a graphic for code as it just wastes unnecessary time retyping when it could have been copied and pasted instead. Remember this is about learning, and often times running the code before/after is part of that process so try not to inhibit such behavior.

    I will continue to use graphics for my questions. If you compare the ratio of correct vs incorrrect answers on questions that can be copied and pasted vs anwers that can't you'll quickly see that many people care more about gathering points than about learning. If having to retype the code encourages at least some of them to use their brains instead of their right mouse button, I'm happy.

    But I do hear you on the learning. For my future questions with code as a graphic, I'll try to post the code in a copy/paste format in the forums as soon as possible. I may not always be online when the question is published, and I may not always remember, but you may remind me of this promise.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • At first I was a little annoyed with the graphics since I have to type it in to test 😛

    However I agree with Hugo. I think it encourages more learning. You'll either try to figure it out, or you'll type it in, which helps cement it in your mind. If you just want to copy paste, get the answer and move on, fine, but I'm not sure we want to help you with that. What's the point of that?

  • Graphic fixed.

  • This is a very good question, thank you Ron. I answered incorrectly because I read columns as rows, the number of rows should be 2, so I got my answer wrong.

    Since I worked with SQL Server 2000 in the past where there was a need for tally table, which typically was created as

    select top 8000 identity(int, 1, 1) number into dbo.numbers from some_cross_join;

    I would not have any doubts about number of columns in your question, but I had to read the question correctly!

    I still liked it. Thank you.

    Oleg

  • I agree the graphic is fine... removes the temptation to copy/paste instead of trying to figure it out on your own.

    With that said, like others, I did not read the question correctly and answered for rows instead of columns. :crazy:

    Good question and demonstration of the identity function. If nothing else, reminds me to sloooow down and read the question.

    David

Viewing 15 posts - 16 through 30 (of 53 total)

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