Solved

Display literal if field exists

Posted on 2008-06-24
2
208 Views
Last Modified: 2010-04-21
Hi

I have a sql statement

select HouseNumber, Street, apartment,  HouseNumber+' '+Street='  '+apartment  as FullAddress from streetable

I want to be able to display the word ' Apartment ' in they have an apartment else just display the housenumer and street

thanks chuck
0
Comment
Question by:charlesbaldo
2 Comments
 
LVL 12

Accepted Solution

by:
jgv earned 500 total points
ID: 21861881
select HouseNumber, Street, apartment,  CASE WHEN LEN(apartment) > 0 THEN 'Apartment' ELSE HouseNumber + ' ' + Street END As FullAddress from streetable
0
 

Author Closing Comment

by:charlesbaldo
ID: 31470426
Perfect, Thansk for the quick response
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now