Solved

Display literal if field exists

Posted on 2008-06-24
2
224 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 34
Attaching Database Failed ? 3 37
Refresh Dev server with Production database 8 27
SQL Server 2012 r2 - Varible Table 3 19
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

815 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

9 Experts available now in Live!

Get 1:1 Help Now