Set default value or binding to another column

Answered Set default value or binding to another column

  • Tuesday, August 25, 2009 6:30 PM
     
     
    I want the default value for a field to be equal to another field within the same record, I tried to set Default Value or Binding of this column to a source column but it doesn't work, should I create a Trigger instead?

All Replies

  • Tuesday, August 25, 2009 6:52 PM
    Moderator
     
     Answered
    Yes, that would have to be done by a trigger. A default object or default constraint cannot refer to "data" in the table or row. You could use a user-defined function in your default definition, but you still don't have anything with which you can find "this row" with...
    Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi
    • Proposed As Answer by Mark Han [MSFT] Thursday, August 27, 2009 7:16 AM
    • Marked As Answer by Mark Han [MSFT] Wednesday, September 02, 2009 2:35 AM
    •