set a default value for a column with the value of another one in the same table

  • Hi

    someone can tell me if is it possible to set a default value for a column, with the value of another one in the same table using the "Default value or Binding" property in the tables design mode?

    Any help appreciated

    Best Regards,

    mrstavares

  • Yes this is possible vis sp_binddefault (not via design mode , TSQL only).

    But - word of warning, this will be removed in a future release of sql-server.

    If you wanted to ensure a default matched across multiple columns for design mode..

    Create a function - which returns the default value.

    Put in for the default value: "fn_name()" for the columns required.

    This will then ensure you can get the same values back for those columns.

    In terms of linking to a default value on another column, this is not possible directly (but would be possible via a user created function).

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply