Link to home
Start Free TrialLog in
Avatar of kamleshmistry
kamleshmistry

asked on

more quick points sql server -- iif


I want to create a formula field.

if area code is blank then formula should be
[LocalNumber]

if area code is not blank then formula should be
[AreaCode] + '-' + [LocalNumber]

How do I do this in sql server formula field?

Avatar of kamleshmistry
kamleshmistry

ASKER

p.s.,

vb.net supports iif

iif(  condtion,  true part,  false part)

where true part is an expression
and
false part is an expression


SOLUTION
Avatar of adathelad
adathelad
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you all sure?

By the way, what I am doing is in the design table section, I am creating a new column.

I create a new column, and then in the Formula textbox entry, I start typing a formula...  

It is a single line text-box...
See above comment,

When I enter a simple forumla like this:

CASE WHEN TRUE Then '-' ELSE '' END

I get the error that the formula is not a valid formula

The above is exactly what I typed into the Formula text box in the columns tab for a new column in the design table screen....



P.S.

I AM NOT DOINT A SQL SELECT


P.S.

THEN WHY ARE YOU POSTING IN THE SQL TA...this sounds like a vb.net question

no, no...
not a vb.net question.

a sql server question.
create a new database table and create a new field.

there is a text box for "formula" to create a formula field.
I believe the way this works is that no storage is used for formula fields.  It is evaluated and displayed, and can be made available to dataset, but does not use up any hard disk storage...

Question is related to Sql server...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial