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
 General SQL Server Forums
 New to SQL Server Programming
 How can i add a column to an existing table

Author  Topic 

landau66
Yak Posting Veteran

61 Posts

Posted - 2007-11-14 : 06:05:29
Hi everyone!

I just started with SQL and SQL Server 2005. I cantfind in my books how to add a column to an existing table. It should be a primary key, auto_increment column.

Hope someone can help, many thanks in advance

Greetings from Vienna Austria

landau

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-14 : 06:29:22
In Books Online I found this syntax
ALTER TABLE	Table1
ADD Col1 INT IDENTITY(1, 1) PRIMARY KEY NONCLUSTERED



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-11-14 : 06:53:15
if you want to add a new column as last column in the table, you have to use the query by peso.
and if you want to add a column in the middle of a table, you have to go to the management studio

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page
   

- Advertisement -