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 |
|
Bernhard
Starting Member
12 Posts |
Posted - 2004-11-12 : 03:32:47
|
| Hello! Please help me!I've got the following problem:First i do the following:ALTER TABLE ANYTABLEHERE ADD [test] bit DEFAULT 0 NULLThen the following:ALTER TABLE DROP [test]The following error occurs:[Microsoft][ODBC SQL Server Driver][SQL Server]The object 'DF__TBL_Subscr__test__17B8652E' is dependent on column 'test'.This all is dynamicly so how can I find all constraints which are here or why are they here? |
|
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2004-11-12 : 04:01:30
|
| in your query "ALTER TABLE DROP [test]" I guess you are trying to drop a table, right? If so then use drop table [test]May be I mis-understood you question |
 |
|
|
Bernhard
Starting Member
12 Posts |
Posted - 2004-11-12 : 04:07:08
|
| Sorry!ALTER TABLE myTable DROP COLUMN [test] |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2004-11-12 : 07:18:22
|
A default is a constraint and SQL Server has named it using its own naming conventionTo add and remove the column, you probably need to add and remove the constraint in the same wayALTER TABLE ANYTABLEHERE ADD [test] bit DEFAULT 0 NULLALTER TABLE ANYTABLEHERE ADD CONSTRAINT DF_ANYTABLEHERE_test DEFAULT (0) FOR [test]ALTER TABLE ANYTABLEHERE DROP CONSTRAINT DF_ANYTABLEHERE_testALTER TABLE ANYTABLEHERE DROP COLUMN [test]Andy |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-11-12 : 08:40:45
|
| We always NAME all our contstraints (rather than letting SQL allocate a random name) - so if we have to drop them we can drop the constraint, by name, first.Kristen |
 |
|
|
|
|
|