String in SQL Server

1. Concatenate two string type columns using space function in SQL server.

The space function is used to concatenate two string columns separated by space.

Syntax

SELECT column_name1 + space(1) + column_name2
FROM table_name


Consider the following table titled 'Students', which contains information of the students.

Write a Query to concatenate two columns using space function.

Student_IDLastNameFirstNameMarks
1PatilRavi60
2MoryaSurendra60
3SinghJaya78
4PanditPrajakta55

SELECT FirstName + space(1) + Last_Name AS Name
FROM table_name


The result is shown in the following table.

Name
Ravi Patil
Surendra Morya
Jaya Singh
Prajakta Pandit