June 12, 2010 at 11:56 pm
Comments posted to this topic are about the item SELECT INTO
June 13, 2010 at 1:13 am
I got it wrong because I didn't read the question correctly, I thought it was asking how many rows where returned.
But in any case even 3 is not the correct answer, because as the graphic is displayed you would get an error on the CREATE TABLE statement.
June 13, 2010 at 9:35 pm
Come on, give the guy a break - you can see that Null has been cropped off! Not another huge discussion on assumptions!
I am on the other side this time, as I read the question right, made the correct assumptions, & got it right 🙂
June 13, 2010 at 11:14 pm
antony-688446 (6/13/2010)
Come on, give the guy a break - you can see that Null has been cropped off! Not another huge discussion on assumptions!
But for all you know there could have been more cropped off. say "ll, Field3 int NULL)" or anything else that could have caused an error, so you only assumed that what was cropped was "ll)".
What it comes down to is either we have to be able make assumptions/corrections to the code, or the correct answer should be based on exactly what is shown. (Which means the person/process posting a new question has to validate that it came out correctly.)
June 14, 2010 at 12:00 am
i didn't read question correctly, and got it wrong... :(. anyway good question, but presented badly...
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
June 14, 2010 at 12:03 am
good question on select into...
I had one point to add.
the following gives an error.
select IDENTITY(int,100,5),* into #temp3 from
testread
there is no alias for identity column.so it shold throw an error.because every column has name in database. without column name it throws error.
one point we should remember is all columns must have a name when we copy data using select into.here identity column should have alias, then it will execute sucess.with out alias for functions when we copy data using select into it throws an error.For CTE also it sholud apply.
for all functions and numerics it also applies.
Please forgive me for my english.I will improve.
Malleswarareddy
I.T.Analyst
MCITP(70-451)
June 14, 2010 at 12:07 am
i guess bitbucket has already provided the alias in his question!
malleswarareddy_m (6/14/2010)
good question on select into...I had one point to add.
the following gives an error.
select IDENTITY(int,100,5),* into #temp3 from
testread
there no alias for identity column.so it shold throw an error.because every column has name in database. without column name it throws error.
one point we should remember is all columns must have a name when we copy data using select into.here identity column should have alias, then it will execute sucess.with out alias for functions when we copy data using select into it throws an error.For CTE also it sholud apply.
for all functions and numerics it also applies.
Please forgive me for my english.I will improve.
June 14, 2010 at 12:08 am
yep, i too assumed it to be NULL and i got it correct... 😀
antony-688446 (6/13/2010)
Come on, give the guy a break - you can see that Null has been cropped off! Not another huge discussion on assumptions!I am on the other side this time, as I read the question right, made the correct assumptions, & got it right 🙂
June 14, 2010 at 12:28 am
I cant see any scalar value getting inserted or am i missing something
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
June 14, 2010 at 12:30 am
Nice Question on the Select Into
for a second i thought Question as How many Rows then while selecting the answer i saw it as columns :hehe:
June 14, 2010 at 12:44 am
Nice question, although not that hard for me as I use SELECT INTO a lot.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 14, 2010 at 12:48 am
sharath.chalamgari (6/14/2010)
Nice Question on the Select Intofor a second i thought Question as How many Rows then while selecting the answer i saw it as columns
Oh. And i just saw it after you pointed it out. I read the question very carefully and still missed it. Good question though.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
June 14, 2010 at 2:37 am
Read the question correctly, assumed a cropped NULL... come on! people, stop being pedantic!!
Still got it wrong, knew the correct answer but, through a lack of confidence, suspected a trick in the question and went with 2 instead.
Doh!! :doze:
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
June 14, 2010 at 2:59 am
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?
June 14, 2010 at 3:26 am
I don't really get the discussion on the chopped off graphic. If you assume an extra column there, the answer would be 4, which was not listed - making it obvious that no column was chopped off.
I am surprised that this relatively simple question is worth 2 points. It made me wonder for a time if I was missing something. I was almost tempted to choose the "error" because the "Int" (instead of "int") would cause an error when run in a database with case-sensitive collation. But since case insensitive is the more common choice, Ron is the question author, and nothing was mentioned about collation, I decided that it was safe to assume the more standard case insensitive collation.
I'm not sure what the intended lesson of the question is, though. Maybe the use of the IDENTITY() function in SELECT INTO?
Viewing 15 posts - 1 through 15 (of 53 total)
You must be logged in to reply to this topic. Login to reply