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 |
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2006-06-29 : 00:55:38
|
Hi friendsam droppping a column thru sql stmt and am getting following errorThe object 'DF__s_datavie__Overr__1DA648AE' is dependent on column 'OverrideCol'.ALTER TABLE DROP COLUMN OverrideCol failed because one or more objects access this column.bcoz i've a default constraint on this columnmy question is, how can i get list of default constraints on this column so that i can drop them first before dropping column. as you'll know that the constraint name can be different on each server having this table so i need to do this.Thanks for the ideas.Cheers |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-29 : 01:00:54
|
useselect object_name(cdefault) as Default_Constraintfrom syscolumnswhere id = object_id('table_name')and name = 'column_name' KH |
|
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2006-06-29 : 01:12:05
|
Thank you very much "kh "that worked beautifully.Cheers |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-29 : 01:18:01
|
You might also want to check for CHECK CONSTRAINTS before dropping the column KH |
|
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2006-06-29 : 01:29:14
|
thanks KH.in this case i dont . so i should be fine.Thanks for ur help.Cheers |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-29 : 01:50:07
|
SELECT cols.name as column_name, c_obj.name as constraint_name,t_obj.name as table_name FROM sysobjects t_obj, sysobjects c_obj, syscolumns cols WHERE cols.id = t_obj.id AND c_obj.id = cols.cdefault AND c_obj.xtype = 'D'MadhivananFailing to plan is Planning to fail |
|
|
|
|
|