Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Create identity field using Select INTO

Author  Topic 

rwaldron
Posting Yak Master

131 Posts

Posted - 2006-09-04 : 06:17:44
Hi all,
I have a table that gets created from a query using
Select * INTO Table_Name.

How do I also add an autonumber column to this table ?

I know how to create the field using create table command
ie:CREATE TABLE t_test(
id INTEGER IDENTITY
PRIMARY KEY

But I can't use create table as I need the table populated from query results.. So I need to use Select INTO

Any help please.
Thx,
Ray.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-04 : 06:22:52
Select name, rowidcol = identity(int, 1,1) INTO Table_Name from master..spt_values

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

rwaldron
Posting Yak Master

131 Posts

Posted - 2006-09-04 : 06:58:01
Thx a million,

that worked

Ray..
Go to Top of Page
   

- Advertisement -