Avatar of Nigel Keith-Walker
Nigel Keith-Walker
Flag for Australia asked on

Negative isnull?

I have a stored procedure that selects details from a customer file to build a full name and full address.
The select statement interposes spaces and commas into the full address.
ALTER  PROCEDURE [dbo].[sp_Name_Addr] 
(isnull([FirstName],'') +' '+	ISNULL([LastName],'')) as Fullname, 
(ISNULL([StreetNumber],'') + ' ' + ISNULL([Address],'')+','+ ISNULL([Suburb],'')+','+ISNULL( [PCode],'')+','+ ISNULL([State],'')+','+ ISNULL([Country],'')) as FullAddr,[ID], [Status]
FROM [tblCustomer]
Where Firstname is Not null
and Status <> 'Expired'
ORDER BY Fullname

Open in new window

Some of the addresses have null in street number.  This means that the full address commences with a space.  
Tried to put NOT isnull(streetNumber,' ') into the select statement but the NOT is not accepted.
Any suggestions?
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
Nigel Keith-Walker

8/22/2022 - Mon
Ryan Chong

you need to include ltrim and rtrim functions into ur sp
Ryan Chong

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Nigel Keith-Walker

LTRIM worked fine in my stored proc.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.