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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 IDENTITY property

Author  Topic 

mahesh.vsp
Starting Member

5 Posts

Posted - 2007-01-04 : 05:12:32
Hi pals,

I need to add an identity property for a column using only T-SQL and not Enterprise Manager. I have tried it but i am getting the following error. How to fix it.


create table parent
(id int,
name varchar(20)
)
-- not null
ALTER TABLE parent ALTER COLUMN id int NOT NULL
ALTER TABLE parent alter column id int IDENTITY(1,1)

I am getting the following error:
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'identity'.

Regards,
mahesh

Kristen
Test

22859 Posts

Posted - 2007-01-04 : 05:45:50
You can't alter a column to become IDENTITY

You either need to add it with that attribute initially, or Drop that column and Add a new one (i.e. with the same name) and the Identity property

Kristen
Go to Top of Page

mahesh.vsp
Starting Member

5 Posts

Posted - 2007-01-08 : 00:05:15
Thank you kristen


Regards,
Mahesh
Go to Top of Page
   

- Advertisement -