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 2000 Forums
 SQL Server Development (2000)
 UNIQUE constraint

Author  Topic 

beliveinmyshelf
Starting Member

15 Posts

Posted - 2007-07-04 : 00:42:52
hi!
i created a table with T-SQL :

create table Table_1
(
Name varchar(20) primary key,
Age int
)

it's okie.

but when i edit this table with :

"alter table Table_1 alter column Age add constraint PK_Age unique"

then it's error.
i want to set "Age" column with UNIQUE constraint.
please help me
thank very munch

pootle_flump

1064 Posts

Posted - 2007-07-04 : 03:42:15
quote:
Originally posted by beliveinmyshelf

hi!
i created a table with T-SQL :

create table Table_1
(
Name varchar(20) primary key,
Age int
)

it's okie.

but when i edit this table with :

"alter table Table_1 alter column Age add constraint PK_Age unique"

then it's error.
i want to set "Age" column with UNIQUE constraint.
please help me
thank very munch

alter table Table_1 
add constraint PK_Age unique nonclustered (Age)
You can also include this in your original make table if interested:
create table Table_1
(
Name varchar(20) primary key,
Age int
, constraint PK_Age unique nonclustered (Age)
)
Go to Top of Page

beliveinmyshelf
Starting Member

15 Posts

Posted - 2007-07-04 : 05:19:01
thank you very munch
i was test.and result is : The command(s) completed successfully.
thank you.
Go to Top of Page
   

- Advertisement -