How to combine 2 or more columns into one column in SQL server

In this article I am going to explain how to combine 2 or more columns into one column in SQL server.


Description:

I have created a table for Users and insert some records.
ID
int
Firstname
varchar(50)
Middlename
varchar(50)
Lastname
varchar(50)
Phonenumber
int
City
varchar(50)

I want to concatenate (combine) first, middle and last into one column.

Implementation:

Run the below given query:

select Firstname+' '+Middlename+' '+Lastname as 'Name',Phonenumber,City from Users

Result:
Name
Phonenumber
City
Vijay Kumar saklani
123456789
Chandigarh
John Smith Smith
876543
London




Post a Comment

0 Comments