SQL Default Values

  • I need to make a column have a value of 4 zero's plus a column that is already in the database.

    Example

    ACCT = 001

    I need acct1 to be = 0000001

    I would like this to happen every time a row is inserted.

    Thanks for any help

    Alexzander N. Nepomnjashiy

    Technical editor for Wrox Press:
    "SQL Server 2000 Fast Answers"

    Technical editor for Apress:
    "Honeypot for Windows"
    "SQL Server Yukon Revealed"

  • If the rule is as simple as always adding 4 zeros to the front of an existing column, why not use a view instead of storing this information?

  • Otherwise I would think that a computed column would do what you want to do.

    I would still think that either your rule is going to be more complex than stated or that a view which did not store this redundant data (4 zeros) but appended it dynamically would be a better choice.

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

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