SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Our Services
Contact
  1. SQL
  2. CONCAT function

Text copied!

« Previous
Next »

CONCAT function

June 4, 2023, 7:05 p.m. under SQL

  • Hi! You should check DATEADD function post first.

    In SQL, CONCAT function is used to combine two or more strings together into a single string.

    What is a String?

    In SQL, A string is a data type used to store data that can contain combination of numbers, letters, whitespaces and symbols. In simple term, String is a word or a sequence of characters.

    What is a Substring?

    A substring is a consecutive sequence of characters or a portion of a string.

    The syntax of the CONCAT function generally looks like this :
    CONCAT(string1, string2, string3, ...)
            

    • Specify the 'string' in single quotes ( ' ' ) or 'column' that you want to combine into a single string.

    • There is no limit to the number of strings or columns that can be passed as arguments.

    Here's an example of how you might use the CONCAT function :

    1. Let's assume we have a table named "[Employees]".

    CONCAT function

    2. Let's assume you want to add 'dollar sign $' before each salary value.

    3. Run below SQL statement :

    SELECT CONCAT('$', Salary)
    FROM [Employees];
            

    4. In above statement, CONCAT function combines the substring1 value 'dollar $' with all the values from the Salary column in substring2.

    CONCAT function
    Remember :

    Using this function in a select statement won't modify the [Employees] table directly, but it will only be reflected in the select statement's output.

    To enhance your understanding of 'SQL functions', be sure to check out our next tutorial.

    Frequently Asked Questions :

    What is concat function in SQL?

    CONCAT function in SQL is used to combine two or more strings into a single string.

    How do I concatenate 3 columns in SQL?

    To concatenate 3 columns in SQL, use CONCAT function with the three column names separated by commas.

    What is the use of concat ()?

    The CONCAT() function is used to concatenate strings in SQL, combining them into one.

    What is ||' '|| in SQL?

    In SQL, ||' '|| is a concatenation operator used to join two strings along with a space between them.
    Thank You! You should check LEN function post next.
    « Previous
    Next »
    RELATED :

    What is SQL

    What is T-SQL

    Difference between DBMS and Data Warehouse

    Download SQL Server

    Install SQL Server

    Download SQL Server Management Studio SSMS

    SQL Server Management Studio

    SQL Database

    Download database

    Restore database

    Backup database

    Attach database

    Detach database

    Create database

    Delete database

    Rename database

    Select database

    Database offline

    Database online

    SQL Commands

    SQL Tables

    Create table

    Truncate table

    Delete table

    Rename table

    Select table

    Alter table

    SQL Data Types

    SQL Comments

    SQL Constraints

    SQL Joins

    SQL inner join

    SQL left join

    SQL right join

    SQL full join

    SQL cross join

    SQL self join

    INSERT INTO SELECT statement

    INSERT INTO statement

    SQL Clauses

    SELECT clause

    FROM clause

    WHERE clause

    GROUP BY clause

    HAVING clause

    ORDER BY clause

    JOIN clause

    UNION clause

    UNION ALL clause

    TOP clause

    DISTINCT clause

    SQL Operators

    SQL Arithmetic operators

    SQL Comparison operators

    SQL Logical operators

    UNION operator

    UNION ALL operator

    INTERSECT operator

    EXCEPT operator

    LIKE operator

    NOT LIKE operator

    IN operator

    NOT IN operator

    IS NULL operator

    IS NOT NULL operator

    EXISTS operator

    NOT EXISTS operator

    BETWEEN operator

    NOT BETWEEN operator

    SQL Functions

    SQL Built-In functions

    CHARINDEX function

    DATEADD function

    LEN function

    REPLACE function

    SUBSTRING function

    CASE statement

    GETDATE function

    DATEPART function

    DATEDIFF function

    CAST function

    TRY_CAST function

    CONVERT function

    TRY_CONVERT function

    ISNULL function

    NULLIF function

    COALESCE function

    SQL Window functions

    ROW_NUMBER function

    RANK function

    DENSE_RANK function

    IIF function

    CHOOSE function

    SQL Store Procedure

    Store Procedure vs. Function

    SQL Subquery

    SQL Aliases

    Temp table

    SQL Error Handling

    SQL Variables

    SQL Views

    SQL Merge

    SQL CTE

    SQL WITH TIES

    Define Transaction in DBMS

    ACID properties in DBMS

    Types of Triggers in DBMS


    • Have Some Questions?
    logo

    Elevate your data experience with SQL excellence

    Quick Links
    •  Home
    •  SQL Tutorial
    •  SQL Syntax
    •  Our Services
    Our Services
    • Web Development
    • BI Development
    • Data Warehousing
    • Data Integration ETL


    Follow Us

    GST Registered: XXAXXXXXXXZX
    Mumbai, Maharashtra, India support@sqlforgeeks.com

    © 2025 Copyright™ | All Rights Reserved | Privacy Policy