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.
| Author |
Topic |
|
tvspsekhar
Starting Member
20 Posts |
Posted - 2010-03-25 : 02:57:07
|
| please help me in dropping the check constraint in a table which I have created already.for example :create table random (eno int, ename varchar(10), check(eno>10));A table named random was created using the above statement. Now if I want to drop the check constraint, please give the solution.tvspsekhar |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-25 : 03:02:52
|
quote: Originally posted by tvspsekhar please help me in dropping the check constraint in a table which I have created already.for example :create table random (eno int, ename varchar(10), check(eno>10));A table named random was created using the above statement. Now if I want to drop the check constraint, please give the solution.tvspsekhar
ALTER TABLE random DROP CONSTRAINT constraintname |
 |
|
|
tvspsekhar
Starting Member
20 Posts |
Posted - 2010-03-25 : 03:06:48
|
| Thank U Mr haroon2k9. But While creating the table I have not given any name to the constraint. tvspsekhar |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-25 : 04:54:30
|
| Find the name of the constraint.b4 execute change the table name and then do below and drop it thendeclare @name nvarchar(32), @sql nvarchar(1000)-- find constraint nameselect @name = O.name from sysobjects AS Oleft join sysobjects AS T on O.parent_obj = T.idwhere isnull(objectproperty(O.id,'IsMSShipped'),1) = 0 and O.name not like '%dtproper%' and O.name not like 'dt[_]%' and T.name = 'tbalename' print @name |
 |
|
|
tvspsekhar
Starting Member
20 Posts |
Posted - 2010-03-25 : 05:54:35
|
| Thank U verymuch Mr haroon2k9tvspsekhar |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-25 : 05:58:40
|
quote: Originally posted by tvspsekhar Thank U verymuch Mr haroon2k9tvspsekhar
Welcome. |
 |
|
|
|
|
|