I'm a newbie to MSSQL7, and am a bit mystified as to how to proceed.
I need to write a T-SQL script to update a database without disturbing
existing data. Part of the update includes clearing the NULL flag and
setting a default value.
I have code to clear the NULL flag. I can also set a default value, but
only if one doesn't already exist.
To change a default, the documentation for ALTER TABLE says that the
existing DEFAULT must be dropped, but it doesn't say how.
It appears that the default value is actually a constraint. Quite
often, the constraint is named DF_<table>_<column>, but not
necessarilly. If I can find the constraint name, it appears that I can
drop it and then add a new default value.
How can I find the name of the constraint that implements the DEFAULT
value?
How can I find out if the column currently has a DEFAULT value?
Am I going at this wrong?
Thanx!
-----------------------------------------------------------------------
Chris Scheers, Applied Synergy, Inc.
Voice: 817-237-3360 Internet: ch...@applied-synergy.com
Fax: 817-237-3074