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

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to select title,firstname,lastname

Author  Topic 

mark1504
Posting Yak Master

103 Posts

Posted - 2004-09-13 : 12:36:36
The subject seems so simple that there has to be a catch, right? :-)

I want to select full names including titles, where a title exists.

So this...

SELECT ISNULL(Title,'')+' '+Firstname+' '+Lastname FROM etc

yields...

Mr Joe Smith
Bill Jones
Dr Alan Green
Phil Black

What's the best way to eliminate the first space?

Thanks
Mark

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2004-09-13 : 12:38:46
SELECT CASE WHEN ISNULL(Title,'') <> '' THEN ISNULL(Title,'') +' ' ELSE '' END + Firstname+' '+Lastname
Go to Top of Page

mark1504
Posting Yak Master

103 Posts

Posted - 2004-09-13 : 13:04:35
Thanks.

Hey, what happened to my spaces???
Bill and Phil are meant to have a space in front of them, but the forum didn't include them.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-09-13 : 13:12:28
ISNULL(Title + ' ','') + FirstName + ..... etc



- Jeff
Go to Top of Page

mark1504
Posting Yak Master

103 Posts

Posted - 2004-09-13 : 13:19:30
Yep! That'll do nicely!

Thanks
Mark
Go to Top of Page
   

- Advertisement -