Phil Parkin (8/17/2012)
Missing something, I'm afraid.SELECT ... INTO
always creates a new table. When it creates that table, uses the data types of the source columns, but not primary keys or identity definitions. So, in your example, Archive.MyTest.Id will not be an IDENTITY column, despite your comment to the contrary. It's just a bog-standard INT.
Sorry Phil but this is incorrect - here's the generated script for table Archive.MyTest:
CREATE TABLE [Archive].[MyTest](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Descript] [varchar](30) NULL
) ON [PRIMARY]
Archive.MyTest.Id is an IDENTITY column.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden