Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

INTO Identities Expand / Collapse
Author
Message
Posted Monday, May 13, 2013 3:22 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 10:21 AM
Points: 1,767, Visits: 6,387
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
Post #1452019
Posted Monday, May 13, 2013 3:27 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 3:22 AM
Points: 3,274, Visits: 1,298
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).
Post #1452020
Posted Monday, May 13, 2013 3:45 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 3:05 AM
Points: 2,685, Visits: 784
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.
Post #1452024
Posted Monday, May 13, 2013 5:01 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 12:17 PM
Points: 1,837, Visits: 2,180
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
Post #1452042
Posted Monday, May 13, 2013 7:00 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 1:05 PM
Points: 3,984, Visits: 5,237
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”
Post #1452080
Posted Monday, May 13, 2013 7:03 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:59 PM
Points: 13,007, Visits: 12,426
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 Moden's 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)
Post #1452081
Posted Monday, May 13, 2013 7:37 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 3:53 PM
Points: 1,899, Visits: 1,424
Koen Verbeeck (5/13/2013)
Danny Ocean (5/12/2013)
Good Basic question. But i surprised that still 51% people are wrong.


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


+1




Everything is awesome!
Post #1452098
Posted Monday, May 13, 2013 7:48 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, August 18, 2014 5:16 AM
Points: 54, 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).
Post #1452101
Posted Monday, May 13, 2013 7:52 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 3:14 AM
Points: 1,348, Visits: 488
Actualy it should be:
SELECT
customerID, count(city) as 'Count'
INTO CustomerCities
FROM Customers
GROUP BY CustomerID
Post #1452106
Posted Monday, May 13, 2013 7:54 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 7:20 AM
Points: 398, Visits: 311
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.
Post #1452108
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse