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)
 SELECT - how to.. STRING TRIM?

Author  Topic 

raoool
Starting Member

3 Posts

Posted - 2006-03-27 : 10:13:32
Need to generate a single text value 'FullName' by combining first name, middle initial, last name. Below works but if there's no middle initial, generates two spaces between first name and last name. How could this be rewritten to suppress the extra space when no middle initial exists (trim the MI + space) from the result.

Select IsNull(Fname, '') + ' '
+ IsNull(MI, '') + ' '
+ IsNull(Lname, '') As FullName,Address1,Address2
From Details Where PID='<<Subject>>'

Thanks in advance!

nr
SQLTeam MVY

12543 Posts

Posted - 2006-03-27 : 10:15:02
Select IsNull(Fname + ' ', '')
+ IsNull(MI + ' ', '')
+ IsNull(Lname, '') As FullName,Address1,Address2
From Details Where PID='<<Subject>>'


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

raoool
Starting Member

3 Posts

Posted - 2006-03-27 : 17:41:08
Thank you!

(Monday morning can't see the 's thru the ('s)
Go to Top of Page
   

- Advertisement -