Tuesday, March 27, 2012

Default field to another field

I am using SQL Server 2000. Is there a way to have a field default to the
value of another field if it is not provided? and how?
TIA
AltmanNo, this is not possible.
Alternatively, for similar legitimate requirements, you might consider using
a computed column with a CASE or perhaps use a view.
Anith|||If you are handling all inserts in a stored procedure, this is easy to do.
OR
You could leave the column NULL and if you build a view on this table, do
something like this,
select ... ISNULL(column1, column2)
Questions:
What should happen if you insert the default and the value in the other
column is modified later?
I'll like to know the reason why you need to do this?
"Altman" <NotGiven@.SickOfSpam.com> wrote in message
news:uFRuR1E7FHA.3760@.TK2MSFTNGP14.phx.gbl...
>I am using SQL Server 2000. Is there a way to have a field default to the
>value of another field if it is not provided? and how?
> --
> TIA
> Altman
>
>|||OK I was hoping it would allow it but I suppose the view could work.
Alternatively I thought maybe of throwing an update,insert trigger that says
if it is null then fill it in with the same value as the other field.
"Raymond D'Anjou" <rdanjou@.canatradeNOSPAM.com> wrote in message
news:OkuB6%23G7FHA.476@.TK2MSFTNGP15.phx.gbl...
> If you are handling all inserts in a stored procedure, this is easy to do.
> OR
> You could leave the column NULL and if you build a view on this table, do
> something like this,
> select ... ISNULL(column1, column2)
> Questions:
> What should happen if you insert the default and the value in the other
> column is modified later?
> I'll like to know the reason why you need to do this?
> "Altman" <NotGiven@.SickOfSpam.com> wrote in message
> news:uFRuR1E7FHA.3760@.TK2MSFTNGP14.phx.gbl...
>

No comments:

Post a Comment