How To Concat Columns In SQL

In this article, we will learn how to Concat columns in SQL.

Below is a selection from the “tblEmployees” table:

SELECT * FROM tblEmployees;

  • Using CONCAT() function:

The string function, CONCAT() is used to add two or more strings together.

Please check How To Use String Functions In SQL, to get understand other SQL string functions.

SELECT CONCAT(EmpName, ', $', Salary) AS NameSalary 
FROM tblEmployees;
  • Without using CONCAT() function:
SELECT EmpName + ', $' + CONVERT (VARCHAR, Salary) AS NameSalary 
FROM tblEmployees;

Output

Both methods return the same output.

Also, check How To Use Server Profiler In SQL

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories