Hey guys, I am new to SQL and was wondering if anyone can help
me with a question. Listing the full names is easy with Aliases but I do not know how to omit the middle column in case of no middle initial. Can anyone please explain how to get that done for the following question please?
[fname]+' '+[minit]+'.'+' '+[lname] as fullname
from [dbo].[employee]
List the full names of all employees in the format similar to “Alfred T. Pennyworth”. If they do not have a middle initial, omit the initial and have a space only
For an employee table in Pubs database with three different columns holding the First name, Middle Initial and Last names, I am supposed to display them in the format of “Alfred T. Pennyworth”. However, in case the middle initial column has no data, it has to omit the data and skip the column completely and display first name and middle name as “Alfred Pennyworth”. How is this possible?
I did the following but it still has the ".'' after the first name even in case of no middle initial and that's not desirable. I need to have the syntax omit the whole middle initial column in case it has a null value.
select[fname]+' '+[minit]+'.'+' '+[lname] as fullname
from [dbo].[employee]