T-SQL Column Default

Posted on 2009-12-29
Last Modified: 2012-05-08
I'd like to set the default value of a column in a table equal to the value of another column in the same table.  This is a temporary vlue until it get's updated later.  I need the column to be unique, so this is why I am setting it equal to the key value initially.

How do I indicate this default (if possible).  I can do it programatically on the insert.

FYI.  I'm using MS SQL Server 2005

Thanks, in advance,
Question by:hefterr
    LVL 60

    Accepted Solution

    You can't set a default to the value of a different column.
    LVL 75

    Assisted Solution

    by:Aneesh Retnakaran
    the only way to do that is to create a trigger, which i wont prefer for a highly transactional system
    LVL 1

    Author Comment

    Ok Thanks - I'll handle it in the program doing the initial INSERT.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
    PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now