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


INTO Identities


INTO Identities

Author
Message
Steve Jones
Steve Jones
SSC Guru
SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)

Group: Administrators
Points: 145221 Visits: 19425
garrett.moffitt (5/15/2013)

I have a table, Customer, with the CustomerID as an identity. I run this query:

select
customerID, count(city) as 'City'
into CustomerCities
from Customer
group by CustomerID
Does the CustomerCities table have a column with the identity property?


Maybe. Doesn't have to have one. So I'm not sure how one would give a definitive answer.
Could just have two int columns.

Of maybe it's has an identity with Identity_Insert set to on.
IF the customer ID from Customer are higher then that in Custmercities then it may be an Identity


You don't understand the question. The "into CustomerCities" creates a new table. The creation process has to set an identity or not set it. This isn't something you control with this statement.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25841 Visits: 12494
Nice question and good find of yet another error in BOL.

But the only reason I've ever grouped by an identity column was to find duplicates when some not very bright person had been misusing dbcc checkident, so I find this code very strange.

Tom

Dineshbabu
Dineshbabu
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1432 Visits: 569
So finally From which version of SQL server, Identity property is copied into new table eventhough if the query has a GROUP BY clause.

Then next question is it the intended behaviour of sql server or will it be changed in later versions?

These questions might have answered in earlier discussions itself , but i missed in the crowd.

--
Dineshbabu
Desire to learn new things..
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25841 Visits: 12494
Dineshbabu (5/24/2013)
So finally From which version of SQL server, Identity property is copied into new table eventhough if the query has a GROUP BY clause.

Then next question is it the intended behaviour of sql server or will it be changed in later versions?

These questions might have answered in earlier discussions itself , but i missed in the crowd.

Nothing in the earlier discussions as far as I remember.

Logically, if identity property of a column is preserved then that should be independent of whether that column is subject of a group by clause or not, so I don't expect it to change. But also I don't care whether it changes or not because I never expect to use select into with group by an identity column.

Tom

Dineshbabu
Dineshbabu
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1432 Visits: 569
L' Eomot Inversé (5/24/2013)
Dineshbabu (5/24/2013)
So finally From which version of SQL server, Identity property is copied into new table eventhough if the query has a GROUP BY clause.

Then next question is it the intended behaviour of sql server or will it be changed in later versions?

These questions might have answered in earlier discussions itself , but i missed in the crowd.

Nothing in the earlier discussions as far as I remember.

Logically, if identity property of a column is preserved then that should be independent of whether that column is subject of a group by clause or not, so I don't expect it to change. But also I don't care whether it changes or not because I never expect to use select into with group by an identity column.


Ok Tom..

Either it should be changed in BOL or in great SQL SERVER to avoid further confusions.

--
Dineshbabu
Desire to learn new things..
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