Solved

SQL - T-SQL Syntax Question

Posted on 2014-03-18
2
215 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
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert in derived column 7 29
Live Storage Vmotion VMs with shared VMDK 10 57
Hide cell in a table 2 10
innerHTML 7 15
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

776 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