Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have never been to any technical site that shows concern just to anybody with problems...I look forward to also share in the future..."

Geography

Where in the world do Tek-Tips members come from?
TheWkndr (Programmer)
12 Apr 12 10:02
I don't know why I can't find anything about this, but how would one go about using an 'if' statement in a view?
Looking to show SN if FSN is blank. both are text fields.

Not sure when I turned dumb here.  Thanks.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TheWkndr
 

jbenson001 (Programmer)
12 Apr 12 11:18
You would have to use a CASE statement.  Check it out in BOL or on-line.
gmmastros (Programmer)
12 Apr 12 11:36

Quote:

if FSN is blank

Can you be more specific...

What is the data type for FSN?
What is the data type for SN?
When FSN is "blank", does this mean an empty string, or is it NULL?

If a "blank" FSN is really NULL, and the data types for FSN and SN are the same, then you could use the Coalesce function, like this....


Select Col1,
       Col2,
       Coalesce(FSN, SN) As SomeAliasName,
       etc...


The Coalesce function will return the value in the first parameter if it is not NULL.  If the first parameter is NULL, then it will return the value in the second parameter.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close