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_ID | LastName | FirstName | Marks |
---|
1 | Patil | Ravi | 60 |
2 | Morya | Surendra | 60 |
3 | Singh | Jaya | 78 |
4 | Pandit | Prajakta | 55 |
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 |