How to concatenate text from multiple rows into a single text string in SQL Server
Consider a database table holding names, with three rows: Peter Paul Mary Is there an easy way to turn this into a single string of Peter, Paul, Mary? 4 47
Consider a database table holding names, with three rows: Peter Paul Mary Is there an easy way to turn this into a single string of Peter, Paul, Mary? 4 47
It’s easy to find duplicates with one field: SELECT email, COUNT(email) FROM users GROUP BY email HAVING COUNT(email) > 1 So if we have a table ID NAME EMAIL 1 John [email protected] 2 Sam [email protected] 3 Tom [email protected] 4 Bob [email protected] 5 Tom [email protected] This query will give us John, Sam, Tom, Tom because they … Read more
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last month. The community reviewed whether to reopen this question last month and left it closed: Original close reason(s) were not … Read more
How can I add a column with a default value to an existing table in SQL Server 2000 / SQL Server 2005? 4 44
In SQL Server, it is possible to insert rows into a table with an INSERT.. SELECT statement: INSERT INTO Table (col1, col2, col3) SELECT col1, col2, col3 FROM other_table WHERE sql=”cool” Is it also possible to update a table with SELECT? I have a temporary table containing the values and would like to update another … Read more
Also how do LEFT JOIN, RIGHT JOIN and FULL JOIN fit in? 2 27 Assuming you’re joining on columns with no duplicates, which is a very common case: An inner join of A and B gives the result of A intersect B, i.e. the inner part of a Venn diagram intersection. An outer join of … Read more