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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 ALTER table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

CM670
Starting Member

Ireland
2 Posts

Posted - 01/21/2013 :  06:31:53  Show Profile  Reply with Quote
Hi,
I have already created a table and forgot to add in the first row.
This row should auto-increment, be unique and of type int.

I have tried using this statement but i keep getting a syntax error.


alter table 'comp_table'
add column 'comp_id' int null auto_increment unique first;

Can anyone tell me what i am doing wrong?

Thanks.

Edited by - CM670 on 01/21/2013 06:32:45

webfred
Flowing Fount of Yak Knowledge

Germany
8764 Posts

Posted - 01/21/2013 :  06:45:57  Show Profile  Visit webfred's Homepage  Reply with Quote
Here we are on MS SQL Server only. Your syntax doesn't look like MS SQL Server. What is it?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2206 Posts

Posted - 01/21/2013 :  06:48:10  Show Profile  Reply with Quote
This is the syntax in Sql Server...
ALTER TABLE tableName ADD colName int NOT null
identity(1,1) unique


I think yours is MySql. ( auto incremented column should be not null)
ALTER TABLE 'table_name' ADD COLUMN 'id' INTEGER NOT NULL AUTO_INCREMENT FIRST

Post your MySql related queries in www.dbforums.com


--
Chandu
Go to Top of Page

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2046 Posts

Posted - 01/21/2013 :  10:25:23  Show Profile  Visit jackv's Homepage  Reply with Quote
http://forums.mysql.com/ is also a good mysql forum

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000