Home All Groups Group Topic Archive Search About

Concatenate Lname and Fname Columns

Author
2 Mar 2006 6:15 PM
pjscott
I'm using Access 2002 and Sql 2000.

I have a Lname and Fname columns that I'm try to concatenate. I'm trying to
use Lname + ', ' + Fname in a View. But Lname is the things that displays.

What am I doing wrong?

Thanks for the help,

Paul

Author
2 Mar 2006 7:36 PM
David Gugick
pjscott wrote:
> I'm using Access 2002 and Sql 2000.
>
> I have a Lname and Fname columns that I'm try to concatenate. I'm
> trying to use Lname + ', ' + Fname in a View. But Lname is the things
> that displays.
>
> What am I doing wrong?
>
> Thanks for the help,
>
> Paul

Are you using fixed-length character columns? If so, you'll need to trim
the data. For example:

create table #Names (
  LName1 CHAR(20),
  LName2 VARCHAR(20),
  FName1 CHAR(20),
  FName2 VARCHAR(20) )
go

Insert Into #Names Values (
  'Gugick', 'Gugick','David','David')
Insert Into #Names Values (
  'Smith', 'Smith','Dan','Dan')
go

Select
  LName1 + ', ' + FName1 as "Fixed-Length Name",
  LName2 + ', ' + FName2 as "Variable-Length Name",
  RTRIM(LName1) + ', ' + RTRIM(FName1) as "Fixed-Length Name - Trimmed"
from #Names
Go

Drop Table #Names
go



--
David Gugick - SQL Server MVP
Quest Software

AddThis Social Bookmark Button