May 24, 2011 at 12:05 pm
HI ,
i want to alter a column and want to remove the primary key but getting error message
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'IDENTITY'.
my code is
CREATE TABLE T (
int1 int IDENTITY PRIMARY KEY,
bit1 bit NOT NULL DEFAULT 0)
ALTER TABLE T
ALTER COLUMN INT1 INT IDENTITY
May 24, 2011 at 12:09 pm
May 24, 2011 at 12:17 pm
If i drop the whole constraint i will loose identity also..is there any way that will drop primary key but will keep identity constraint....
May 24, 2011 at 12:27 pm
create table test(col1 int identity primary key not null, col2 int)
--check table design. identity specification = yes
insert into test (col2)
values (2),(5),(23)
alter table dbo.test
drop constraint [constraintName]
--check table design. identity specification = yes
have you tested it on a test table?
May 24, 2011 at 12:45 pm
yes it worked..thanks a lot...
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply