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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Create identity field using Select INTO
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

rwaldron
Posting Yak Master

131 Posts

Posted - 09/04/2006 :  06:17:44  Show Profile
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

Sweden
30421 Posts

Posted - 09/04/2006 :  06:22:52  Show Profile  Visit SwePeso's Homepage
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 - 09/04/2006 :  06:58:01  Show Profile
Thx a million,

that worked

Ray..
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.1 seconds. Powered By: Snitz Forums 2000