• jrichards54 (10/28/2012)


    Is it possible to use the "IF" function in a column at design time as the value for that field? I do it regularly in Excel with no problem but I am new to SQL Server and have been unable to figure this one out. I have been using 3 of my own books plus the Online Books but to no avail. If I cannot do it in design, can I create a script (or a stored proceedure) that will do it at run time? Thanks, JRichards54 🙂

    SQL Server only permits constants as default values. You could use a computed column to generate (and contain) a value for you, or a check constraint to ensure that an INSERTED/UPDATEd value matches your criteria. In practice? I'd put the logic into the INSERT script.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]