Is there anyway to set as default value one of the columns or more in SQL Server? I normally use as default value for date only ex: getdate()
but I haven’t tried other columns.
Example:
ID Name Address Remarks
1 Richard USA Name: Richard,Address: USA
I want to concatenate Name and Address as default value or bindings of Remarks. Tried ‘Name: ’ + [Name] + ‘,‘ + ‘Address: ’+[Address] it doesn’t work.
1条答案
按热度按时间gopyfrb31#
You can't directly set computed columns based on other column values within the
DEFAULT
constraint. You can achieve this using computed columns or triggers to generate a dynamic value based on other column values.Computed Column Method:
Trigger Method: