Home > Archive > microsoft.public.sqlserver.server > November 2002 > Adding or Dropping Defaults





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Adding or Dropping Defaults
Douglas Marquardt

2002-11-20, 12:23 pm

Hi All:

I am adding defaults to my columns like this:

ALTER TABLE MYTABLE ADD CONSTRAINT [DF_MYTABLE_UID] DEFAULT (newid()) FOR [UID]

However, I can not figure out how to drop the default.
I tried this:

ALTER TABLE MYTABLE DROP CONSTRAINT [DF_MYTABLE_UID]

but I get an error that it is not a constraint.

So I tried using DROP CONSTRAINT [DF_MYTABLE_UID]
but I get an error "Cannot drop the default 'DF_MYTABLE_RUID',
because it does not exist in the system catalog."

So how do I get rid of the default?
Should I be doing something different to add/remove defaults?


Doug.




Tibor Karaszi

2002-11-21, 9:23 am

Doug,

There's gotta be more to it than that. I just tried below in my machine and it worked fine:

create table MYTABLE (uid uniqueidentifier)
go
ALTER TABLE MYTABLE ADD CONSTRAINT [DF_MYTABLE_UID] DEFAULT (newid()) FOR [UID]
go
ALTER TABLE MYTABLE DROP CONSTRAINT [DF_MYTABLE_UID]

--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=...ublic.sqlserver


"Douglas Marquardt" <no_spam@dummy.com> wrote in message news:uLU#XqLkCHA.2460@tkmsftngp10...
> Hi All:
>
> I am adding defaults to my columns like this:
>
> ALTER TABLE MYTABLE ADD CONSTRAINT [DF_MYTABLE_UID] DEFAULT (newid()) FOR [UID]
>
> However, I can not figure out how to drop the default.
> I tried this:
>
> ALTER TABLE MYTABLE DROP CONSTRAINT [DF_MYTABLE_UID]
>
> but I get an error that it is not a constraint.
>
> So I tried using DROP CONSTRAINT [DF_MYTABLE_UID]
> but I get an error "Cannot drop the default 'DF_MYTABLE_RUID',
> because it does not exist in the system catalog."
>
> So how do I get rid of the default?
> Should I be doing something different to add/remove defaults?
>
>
> Doug.
>
>
>
>



Douglas Marquardt

2002-11-21, 12:24 pm

Hi Tibor:

> There's gotta be more to it than that. I just tried below in my machine and it worked fine:


I just tried it again today -- works fine.
No matter what I did yesterday it didn't.

Guess it was just one of those days...

Thanks!

Doug.



Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net