maqskywalker
asked on
Concatenating name columns
I’m using sql server.
I have a table that has a lastname,firstname and middleinitial columns.
They are these datatypes:
[LastName] VARCHAR(30)
[FirstName] VARCHAR(20)
[MidInit] VARCHAR(1)
So when I run this query
SELECT [LastName],[FirstName],[Mi dInit]
FROM [Emplyoees]
I get this:
LastName FirstName MidInit
Simpson Homer J
Simpson Lisa M
Bunny Bugs
Bonney William H
I would like to create a column called FullName that displays the data in this format LastName, FirstName MidInit
So then the new column would like like this:
FullName
Simpson, Homer J
Simpson, Lisa M
Bunny, Bugs
Bonney, William H
What’s the beat syntax to create this column?
Notice how bugs bunny has no MidInit.
When employee has no MidInit don’t place any character in the string for the middleinit.
I have a table that has a lastname,firstname and middleinitial columns.
They are these datatypes:
[LastName] VARCHAR(30)
[FirstName] VARCHAR(20)
[MidInit] VARCHAR(1)
So when I run this query
SELECT [LastName],[FirstName],[Mi
FROM [Emplyoees]
I get this:
LastName FirstName MidInit
Simpson Homer J
Simpson Lisa M
Bunny Bugs
Bonney William H
I would like to create a column called FullName that displays the data in this format LastName, FirstName MidInit
So then the new column would like like this:
FullName
Simpson, Homer J
Simpson, Lisa M
Bunny, Bugs
Bonney, William H
What’s the beat syntax to create this column?
Notice how bugs bunny has no MidInit.
When employee has no MidInit don’t place any character in the string for the middleinit.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER