473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to Display Column Data in Comma Separated Form in SQL Server

Expand|Select|Wrap|Line Numbers
  1. select stuff((select ','+[Column_Name] from <TableName> for xml path('')),1,1,'')
Dec 5 '11 #1
2 3200
Rabbit
12,516 Expert Mod 8TB
This is the correct syntax
Expand|Select|Wrap|Line Numbers
  1. SELECT Country,  
  2. (STUFF((SELECT ',' + FirstName FROM Employees E2 WHERE  E1.Country = E2.Country ORDER BY FirstName FOR XML PATH(''), TYPE, ROOT).value('root[1]','nvarchar(max)'),1,1,'')) as FirstNames  
  3. FROM Employees E1
Dec 5 '11 #2
Hi Rabbit,
Actually i have written for selecting a single column value from single table..so that was correct .you have sent a replay for selecting a relationship column data ..my query is working fine in my system..sorry if i am wrong...
Dec 12 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: cooldv | last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this code: message = Replace(usermessage, "'", "''"). My problem is DISPLAYING data in an asp FORM, from an an access database,...
12
by: insomniux | last post by:
Hi, I'n in an environment where I cannot make stored procedures. Now I need to make a query with a subquery in the SELECT part which gives a comma separated list of results: SELECT p.id,...
2
by: pesso | last post by:
I have a string that contains the following: string s = "130,41,43,178,41,17,6,78,244,35,202,144,115"; They are comma separated byte numbers, and I need to initialize my byte array with them....
3
by: starman7 | last post by:
I'm attempting a query that gathers product data for a particular product id. One of the items is designer(s) which can be more than one. The product table has comma separated id's of the...
3
by: mahe23 | last post by:
All, How do One convert a comma separated column from a text file into rows in oracle. I have a scenario where the list of comma separated values changes dynamically. It is like: abc, ttt,...
1
by: laxlou | last post by:
Hi, I'm using script to grab following comma separated data from telnet port. (x86, Windows, ActivePerl) There is coming quite a lot of data from port. several lines per second producing hudreds...
0
MMcCarthy
by: MMcCarthy | last post by:
This is a module that imports information to a Query or a Table from comma separated values file in a text format! It is very helpful for getting information from other applications and from files! ...
3
by: beemomo | last post by:
I have two tables - 'Client' and 'Company', and two forms, 'Client' and 'Company', the relationship between two table is 1:many where a company can have one or more client but each of the client...
1
by: mary mathews | last post by:
Hi, I have an access database with Arabic Data. I want to display that data in ASP form(Classis ASP) but it shows only reverse question marks. i have tried with tahoma font in the form,its not...
2
by: smugcool | last post by:
hi, I am very much unaware of working in vb. I have an access database, along with various queries. I wanted to build a form where i can display data of tables,queries in the form. I dont know how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.