SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


INTO Identities


INTO Identities

Author
Message
Toreador
Toreador
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2777 Visits: 8084
I wrongly assumed the point of the question was that the table wouldn't have an identity column because it wouldn't be created at all due to the lack of a column alias Sad
Mighty
Mighty
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4418 Visits: 1700
Slawomir Swietoniowski (5/12/2013)
This question is stated wrong, cont(...) does not have any alias for the name, so, while you will try to execute this code, you will get:

Msg 1038, Level 15, State 5, Line 1
An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.

My guess is that is why only ~50% percent people guessed correctly, the rest might assume that lack of an alias is the "tricky" part of this question...

+1 here too. As far as I know you should be able to copy the query and run it.

But something I found out, which was more interesting, is that when you use a table from a linked server, that it won't create a field with the identity property, even not when the linked server is that instance itself (so a four part name to the current server).
Toni-256719
Toni-256719
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3669 Visits: 976
There is a syntax error in the select statement.
I assumed this was another one of those "trick" questions.
If you're going to submit a QOTD, you do need to make sure
your question is correct and your syntax is valid.
Thomas Abraham
Thomas Abraham
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2731 Visits: 2255
Toni-256719 (5/13/2013)
There is a syntax error in the select statement.
I assumed this was another one of those "trick" questions.
If you're going to submit a QOTD, you do need to make sure
your question is correct and your syntax is valid.


This was just Steve's method for having his code consume fewer resources. ;-)

Please don't go. The drones need you. They look up to you.
Connect to me on LinkedIn
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)

Group: General Forum Members
Points: 8933 Visits: 7281
Och, books online - need i say more?
vary interesting question, thanks, Steve.

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26161 Visits: 17539
Danny Ocean (5/13/2013)

I think nobody check the question before published and everybody should get point for this.


You just got your point back by posting. If you want some points, you are welcome to as many of mine as you wish. :-)

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Dana Medley
Dana Medley
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2494 Visits: 1696
Koen Verbeeck (5/13/2013)
Danny Ocean (5/12/2013)
Good Basic question. But i surprised that still 51% people are wrong. w00t


Yes, because I use INTO combined with a GROUP BY daily to create new tables... Rolleyes


+1 Hehe



Everything is awesome!
gauravupadhyay
gauravupadhyay
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 25
I was wrong here. but the right query will be




SELECT
customerID, count(city) as 'Count'
INTO CustomerCities
FROM Customer
GROUP BY CustomerID


other wise it will not execute.....

definitely CustomerCities will have Identity column as customer table
(mine cause for wrong answer was query provided because i was not able to execute that one and i guessed wrong answer).
palotaiarpad
palotaiarpad
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2096 Visits: 775
Actualy it should be:
SELECT
customerID, count(city) as 'Count'
INTO CustomerCities
FROM Customers
GROUP BY CustomerID
Bobby Russell
Bobby Russell
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1238 Visits: 488
This questions answer is WRONG. I read others saying well you assume this or you take that...NO. The bottom line IS there is NO IDENTITY because the statement will not execute. It's a black and white YES/NO. I understand the authors intent and simple error...but perhaps he was trying to see how many people knew there would be an error without running it. As stated in the quiz, to say the statement produces an identity column in the output is incorrect.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search