?
Solved

SQL - T-SQL Syntax Question

Posted on 2014-03-18
2
Medium Priority
?
229 Views
Last Modified: 2014-03-18
I have a small table with LocationID and Year fields which I would like to manipulate into a view that can be used in a sproc to bind this and additional data to an asp.net control.  For each LocationID I am trying to concatenate the associated years (ordered DESC) into a comma-separated string field which will in turn be bound to my tooltip.

I think this should be doable but I am totally stuck on syntax.  Any helpful experts want to give me a start?  Thanks.
0
Comment
Question by:AJ0718
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 39937913
See the stuff/ForXML path here:
http://sqlandme.com/2011/04/27/tsql-concatenate-rows-using-for-xml-path/

The article explains exactly what you're trying to do.
0
 

Author Closing Comment

by:AJ0718
ID: 39937960
Thank you!  I kept finding lots of articles but nothing that quite fit.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question