About 117,000 results
Open links in new tab
  1. sql server - SQL, How to Concatenate results? - Stack Overflow

    I currently have a SQL query that returns a number of fields. I need one f the fields to be effectively a sub query sub that. The Problem in detail: If I have a table X with two columns, ModuleID and say ModuleValue, how can I write a SQL query to take the results and Concatenate it into one field: EG Results returned from

  2. How to concatenate text from multiple rows into a single text …

    Oct 27, 2015 · SQL Server 2017+ and SQL Azure: STRING_AGG. Starting with the next version of SQL Server, we can finally concatenate across rows without having to resort to any variable or XML witchery. STRING_AGG (Transact-SQL) Without grouping. SELECT STRING_AGG(Name, ', ') AS Departments FROM HumanResources.Department; With grouping:

  3. How do I concatenate text in a query in sql server?

    Aug 1, 2014 · If you are using SQL Server 2005 (or greater) you might want to consider switching to NVARCHAR(MAX) in your table definition; TEXT, NTEXT, and IMAGE data types of SQL Server 2000 will be deprecated in future versions of SQL Server.

  4. How to concatenate in SQL Server - Stack Overflow

    May 3, 2015 · To concatenate strings in SQL Server you can simply use the + operator. Note that if one of the substrings is null then the entire concatenated string will become null as well. therefor, use COALESCE if you need a result even if one substring is null.

  5. sql server - How can I concatinate a subquery result field into the ...

    May 12, 2017 · Answering an old post, just thought it needed an update for newer versions of SQL Server: For SQL Server 2017 use STRING_AGG(expression, seperator) GROUP_CONCAT is MySQL. Prior to SQL 2017, you can also do something like (snipped from our current code base on SQL Server 2016):

  6. SQL Query - Concatenating Results into One String

    I have a sql function that includes this code: DECLARE @CodeNameString varchar(100) SELECT CodeName FROM AccountCodes ORDER BY Sort I need to concatenate all results from the select query into CodeNameString. Obviously a FOREACH loop in C# code would do this, but how do I do it in SQL?

  7. sql - What is the string concatenation operator in Oracle ... - Stack ...

    Jun 29, 2015 · There are two ways to concatenate Strings in Oracle SQL. Either using CONCAT function or || operator. CONCAT function allows you to concatenate two strings together. SELECT CONCAT( string1, string2 ) FROM dual; Since CONCAT function will only allow you to concatenate two values together.

  8. SQL Server: Best way to concatenate multiple columns?

    I am trying to concatenate multiple columns in a query in SQL Server 11.00.3393. I tried the new function CONCAT() but it's not working when I use more than two columns. So I wonder if that's the best way to solve the problem: SELECT CONCAT(CONCAT(CONCAT(COLUMN1,COLUMN2),COLUMN3),COLUMN4) FROM …

  9. How to concatenate many rows with same id in sql?

    SQL Server 2017+ and SQL Azure: STRING_AGG. Starting with the next version of SQL Server, we can finally concatenate across rows without having to resort to any variable or XML witchery. STRING_AGG (Transact-SQL) SELECT ID, STRING_AGG(DisplayName, ', ') AS DisplayNames FROM TableName GROUP BY ID

  10. How to concatenate variables into SQL strings

    Jul 19, 2013 · The trick is that you need to create a string containing the SQL statement. That's because the tablename has to specified in the actual SQL text, when you execute the statement. The table references and column references can't be supplied as parameters, those have to appear in the SQL text. So you can use something like this approach:

Refresh