Solved

SQL Query Function Syntax Help

Posted on 2014-09-23
2
141 Views
Last Modified: 2014-09-23
Hello all,

Can someone give me an example how to do this.  

Select LocationName from CustomerLocation
Where CustId = 1

I am going to get multiple records I want to create a function that will give me back a comma string of Location Names as there could be 1 to Many records for a particular CustId.  Also need to strip the last comma.   So something like a varchar(500) I want to pass back with the return.

Thanks all
0
Comment
Question by:sbornstein2
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40339594
SELECT  STUFF(( SELECT ',' + LocationName
           
             from CustomerLocation
Where CustId = 1
              FOR
                XML PATH('')
              ), 1, 1, '') AS List
0
 

Author Closing Comment

by:sbornstein2
ID: 40339628
awesome thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

809 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