A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/sql/concat-function-in-sql-server/ below:

CONCAT() function in SQL Server

CONCAT() function in SQL Server

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 : Returns :

The function concatenates all the given string and returns them as one whole string.

Applicable to the following versions : Example-1 :

The general working of

CONCAT() function.

Example-2 :

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