Last Updated : 28 Dec, 2020
CONCAT() :This function in SQL Server helps to concatenate two or more strings together. CONCAT() function can accept a minimum of 2 parameters and a maximum of 254 parameters.
Syntax :CONCAT(string_1, string_2, .......string_n)Parameters :
The function concatenates all the given string and returns them as one whole string.
Applicable to the following versions :The general working of
CONCAT() function.
SELECT CONCAT('PYTHON', ' ', 'is', ' ', 'fun!!!') As Combined;Output : Combined PYTHON is fun!!!
SELECT CONCAT ('Every', 'next', 'level', 'of', 'your', 'life', 'demands', 'a', 'new', 'you!') As Combined;Output : Combined Everynextlevelofyourlifedemandsanewyou!
Using a variable with CONCAT() function, we assign the strings to variables and then concatenate them.
DECLARE @Str1 AS VARCHAR(100)='Think' DECLARE @Str2 AS VARCHAR(100)='-' DECLARE @Str3 AS VARCHAR(100)='green' DECLARE @Str4 AS VARCHAR(100)=' ' DECLARE @Str5 AS VARCHAR(100)='Be' DECLARE @Str6 AS VARCHAR(100)='-' DECLARE @Str7 AS VARCHAR(100)='green' SELECT CONCAT(@Str1, @Str2, @Str3, @str4, @str5, @str6, @str7) AS Combined;Output : Combined Think-green Be-green Example-3 :
Concatenating numerical expression using CONCAT() function, here in place of string we combined numeric values.
SELECT CONCAT(13, 03, 1999) AS Combined;Output :
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4