Link to home
Create AccountLog 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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.