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 |
|
alys
Starting Member
5 Posts |
Posted - 2001-12-10 : 10:29:58
|
| I have a table called 'applications' and a field called 'totals' that currently has a default of zero. I want to take this default off - does anyone know the correct syntax?Thanks in advance. |
|
|
JustinBigelow
SQL Gigolo
1157 Posts |
Posted - 2001-12-10 : 10:48:12
|
The command drop default defaultname will remove the default. You can find the name of the the defaultwith sp_help tablename .Justin |
 |
|
|
barmalej
Starting Member
40 Posts |
Posted - 2001-12-10 : 11:35:32
|
| You can also simply open Enterprise Manager, find your table and after selecting 'Design Table' get rid of the proper default value. |
 |
|
|
izaltsman
A custom title
1139 Posts |
Posted - 2001-12-10 : 11:38:41
|
| I'm afraid that will not work. You can't drop a default while it is bound to the column. Defaults can be implemented one of two ways in SQL Server. The way to which Justin is referring is when default is set up as a separate DB object, which can be bound to a field in the table (or to a user-defined datatype). To get rid of such a default, run sp_unbindefault 'applications.totals'After you run this statement, the default will no longer apply to the totals field (and if it is not bound to any other object in your database, then you will be able to drop it like Justin suggests)Another (more common) way to implement defaults is to create DEFAULT constraints on tables. Then, if you wanted to get rid of a default, you could issue an ALTER TABLE command:ALTER TABLE totalsDROP CONSTRAINT <defaultname>You can find out the name of the default by running sp_helpconstraint 'totals'.Ugh! Sniped again! Yeah, if you don't want to do it via scripts, you can use EM as barmalej suggests.Edited by - izaltsman on 12/10/2001 11:43:23 |
 |
|
|
|
|
|