Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select null
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

17 Posts

Posted - 02/27/2014 :  03:17:02  Show Profile  Reply with Quote
select strFastbeteckningTrakt + ' ' + strFastbeteckningBlock + strFastbeteckningTecken + convert(VARCHAR(10), intFastbeteckningEnhet) as Fastighet, strAnlnr

Will mostly give desired result:

Fastighet strAnlnr
HEDBY 2:3 45678

But for some rows these can be null:

which will cause this:

Fastighet strAnlnr
NULL 45678

when i want this:

Fastighet strAnlnr
HEDBY 3 45678

Edited by - akamole on 02/27/2014 03:18:58

In (Som, Ni, Yak)

17689 Posts

Posted - 02/27/2014 :  05:17:27  Show Profile  Reply with Quote
use ISNULL()

select ISNULL(strFastbeteckningTrakt + ' ', '') 
+      ISNULL(strFastbeteckningBlock, '') 
+      ISNULL(strFastbeteckningTecken, '') 
+      convert(VARCHAR(10), ISNULL(intFastbeteckningEnhet,'')) as Fastighet, strAnlnr

Time is always against us

Edited by - khtan on 02/27/2014 05:17:58
Go to Top of Page

Starting Member

17 Posts

Posted - 02/27/2014 :  07:55:40  Show Profile  Reply with Quote
Thank you!
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000