Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
SQL

SQL Server CONCAT_WS Function (Concat with Separator)

- 13.08.20 - ErcanOPAK

The SQL Server CONCAT_WS() function concatenates two or more strings into one string with a separator. CONCAT_WS() means concatenate with separator.

The following shows the syntax of the CONCAT_WS() function:

CONCAT_WS(separator,input_string1,input_string2,[...input_stringN]);
SELECT 
    first_name, 
    last_name, 
    CONCAT_WS(', ', last_name, first_name) full_name
FROM 
    sales.customers
ORDER BY 
    first_name, 
    last_name;

The following picture shows the partial output:

SQL Server CONCAT_WS by example

Related posts:

Return number of rows affected by UPDATE statements in SQL

How to get the first and last date of the current year in SQL

How to get difference between 2 tables in MSSQL

Post Views: 26

Post navigation

How to refresh a DIV content with Javascript
Default Values for Data Types in C#

Leave a Reply Cancel reply

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

December 2025
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Nov    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (915)
  • Get the First and Last Word from a String or Sentence in SQL (798)
  • How to select distinct rows in a datatable in C# (772)
  • How to add default value for Entity Framework migrations for DateTime and Bool (772)
  • How to make theater mode the default for Youtube (592)
  • Add Constraint to SQL Table to ensure email contains @ (558)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (533)
  • Average of all values in a column that are not zero in SQL (505)
  • Find numbers with more than two decimal places in SQL (421)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (416)

Recent Posts

  • VS “Auto-Using Not Working” — The Broken Roslyn Cache Fix
  • WP “Plugin Update Breaks Site” — The Rollback Life-Saver
  • Windows 11 “SSD Suddenly Slow” — Disabled Write Caching
  • Windows 11 “CPU Stays High for No Reason” — SearchIndexer Loop Bug
  • AJAX “CORS Works in Postman But Fails in Browser” — Preflight Hell
  • JS “Object Mutation Side Effects” — The Hidden Reference Bug
  • HTML5 “Form Enter Key Submits Wrong Button” — The Invisible Default Button Rule
  • CSS “Text Overflow Ellipsis Not Working” — The Missing Combo
  • .NET Core “Configuration Not Updating” — Missing ReloadOnChange
  • ASP.NET Core “Middleware Never Executes” — The Ordering Trap

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (915)
  • Get the First and Last Word from a String or Sentence in SQL (798)
  • How to select distinct rows in a datatable in C# (772)
  • How to add default value for Entity Framework migrations for DateTime and Bool (772)
  • How to make theater mode the default for Youtube (592)

Recent Posts

  • VS “Auto-Using Not Working” — The Broken Roslyn Cache Fix
  • WP “Plugin Update Breaks Site” — The Rollback Life-Saver
  • Windows 11 “SSD Suddenly Slow” — Disabled Write Caching
  • Windows 11 “CPU Stays High for No Reason” — SearchIndexer Loop Bug
  • AJAX “CORS Works in Postman But Fails in Browser” — Preflight Hell

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2025 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com