Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Computed Column Formula
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01186698
Message ID:
01186707
Views:
21
>Hi All,
>
>Can I use IF or CASE statement in a computed column formula?
>If not can I create a User Defined Function and then use it in my column ?
>
>Basically this is what I am trying to do in my D column:
>
>If A = 1 Then B+C Else B End If
>
>Thank you,
>Daniel
SELECT CASE WHEN A = 1 THEN B+C ELSE B END AS Col1
       FROM ....
...
or
SELECT B + CASE WHEN A = 1 THEN C ELSE 0 END AS Col1
       FROM ....
...
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform