Development resources, articles, tutorials, code samples, tools and downloads for ASP.Net, SQL Server, Reporting Services, T-SQL, Windows, AWS, SAP HANA and ABAP
SQL concatenation : SQL Concatenate Strings Function for MS SQL Server with T-SQL
T-SQL developers fruequently deal with sql concatenation and with sql concatenate strings functions.
As a sql developer I will try to give samples of sql concatenation example on MS SQL Server with t-sql.
SQL concatenation is being used since early versions of MS SQL Server.
For example for SQL Server 2000, you can sql concatenate strings using COALESCE function.
With MS SQL Server 2005 and T-SQL improvements, sql developers or database administrators has new t-sql concatenation functions and methods. String concatenation in sql can be implemented by using still COALESCE function, as well as new string concatenation methods using FOR XML PATH().
Sample sql tables create code and populate example tables with sample data.
You can execute the below t-sql script in order to create the sql data tables with its sample table rows which we will use later in the tutorial for sql concatenation.
SQL Concatenation on MS SQL Server 2005 and SQL Server 2008 using FOR XML PATH() T-SQL Function
With the new XML functions in T-SQL introduced with Microsoft SQL Server 2005, sql string concatenation can be now implemented using FOR XML PATH t-sql statements as follows :
SQL Concatenation on MS SQL Server 2000 using COALESCE T-SQL Function
Here is a string concatenation function using T-SQL Coalesece function in order to sql concatenate course titles for a given student.