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
 constraint problem

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-01-04 : 07:00:06
Hi
actally, i have a table, having foriegn key and primary key also.
how can i drop these keys and add unique key to that column?

thank you very much

Vinod

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-04 : 07:03:47
1. To drop constraint
Alter Table table-name
Drop Constraint constraint-name


2. To add constraint
Alter Table table-name
Add Constraint constraint-name...


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-01-04 : 07:29:21
Suppose I have column001, column002 and column003 in my table,
i need this constraint on all the three columns. is it possible?

Vinod
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-04 : 07:32:25
Yes.

alter table Table1
add constraint uniq1 unique (column001, column002, column003)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-01-04 : 07:33:56

Thank you Mr.Harsh for your great help.
thank you very much.

Vinod
Go to Top of Page
   

- Advertisement -