Pulling Values Together from Two Fields

How do I merge two values from separate fields using SQL?

An example would be taking the LastName field and placing it before the FirstName field like this: “LastName, FirstName”.

I would then like to generate a whole new field based on this result.

You can accomplish your task simply by ordering the fields in the select list so that last name comes in the select list first.

If you actually want to combine Last Name and First Name so that they look like they came from one entry in one field, then you can issue this instead:

SELECT RTRIM(lastname)+' '+RTRIM(firstname) 

Don’t forget the quotes and the embedded space, otherwise everything will run together most unattractively. I think this solution will get you home.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: