.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Comma-Delimited Output

Posted By: Amit Mehra     Posted Date: April 22, 2010    Points: 2   Category :Sql Server
One of the common tasks performed when retrieving data from a SQL Server database is returning the result as a comma-delimited output instead of a result set. This task can be performed by using a CURSOR selecting the column to be concatenated together. Each row returned by the CURSOR is then concatenated together into a variable separating each one by a comma.

View Complete Post

More Related Resource Links

Dividing a comma delimited string


Hi guys,

I am fairly new to TSQL and need some urgent help on this.

I have a column in a table made up of a string that has data as follows:


I would like to break the long string into different words and then store them in separate columns, so I should have

Column 1: COSTS

Column 2: LEVEL

Column 3: GRADE

Column 4: ITEM

Can someone please help me out with this, taking into consideration the fact that I am a newbie to TSQL.


Thank you

Non Delimited Header in a delimited output file



I have a requirement to make a delimited flat file from a data base table.  The table has some 20+ columns.   I totally understand how to accomplish this part.  What is a bit more  tricky is that I need to create a header row that is not delimited.  The final output would look something like this


$header –Opt1 –Opt2 20101005


Comma delimited procedure Help!


I need some help. This is going to be confusing so bare with me please!

I have a linked server and from what I read you cannot bring over multi-valued items.  And one of the items I need has up to three values for the same variable.  So I have objectClass listed three times on the server I am linked to with three different values for objectClass.

-objectClass | hi

-objectClass| hello 


In the linked server data store objectClass is a list of schemas and in my SQL(2008) DB I just made a table names objectClasses with the data type NAME which is a nvarchar(MAX).  I have an LDAP query that grabs all the NAMES from the objectClass table on the linked server I'm connected to. and then inserts them into that table which was 700 records.

I created another table called Groups, and it has a column named objectClass which I made an nvarchar(MAX).  I need a stored procedure, (was looking at one that used the Comma delimited list) that loops through the linked server data store and put the three objectClass values in a string of some sort and then I can insert that one set of values into the Groups table.

I must do this through SQL, not .NET.

Anyone have an idea to help me out! Thanks!


Comma delimited list in table column


Hi, does anyone know how this can be done?


I have a table which has a varchar column with a delimited list of values seperated by columns.

eg.  24234234,123123,12312312,12312312,1231231


I need to be able to search this table finding all rows where an input number matches any of the numbers in the delimited list.


And ideas?








Comma Quote Delimited



How do i output the results from SQL table to comma quote delimited text file.

For example i should get columns in flat file destination as


Matching every third word in a comma delimited string.


Hello all,

I have to write a .NET program that accepts a string of comma delimited values.  I want to write a regular expression to accept every third value (starting with the sixth).  I have a regex to skip the first three values and return groups of three:


Now I need something to skip the first two words within each group.  Any suggestions?

Thanks in advance

Convert comma delimited record to string array


Is there any efficient way to convert a comma delimited record with quotes to string array?

Say, "Peter","Pan",123,"Hello, is it ok",Test
str[0] = "Peter"
str[1] = "Pan"
str[2] = 123
str[3] = "Hello, is it ok"
str[4] = "Test"

That is comma within quotes are not treated as delimited


Enterprize library 4.1 getting output parameter after adding record in db, plz guide



I need to get output parameter (flag) from db after saving record in database. I am using Microsoft Enterprise Library 4.1 for DB. I am inserting record using I Data reader.

Please guide


Inline conditional output


Is it possible to somehow output some content based upon some conditional check in Razor? If not, I hope this possibility will be added in the future. What I want to do is the following:

<option value="1" @if(ListMode == 1) { = "selected=\"true\"" }>Full list</option>

As I can't figure out a way to do this, I have to either make a helper that does it for me or write duplicate code.

saving XML output from webservice


 I created a webservice that takes casenum as input and gives results as a dataset in an XML.

I could make a web client to display the resulting dataset in a grid view. Pls see my code copied below.

Now I want to create a console client that takes the casenum as input, to call the webservice and saves the resulting xml for further processing, but can't figure out how to just capture the xml to save. Here's the code for my web client. I would appreciate if you could help modify this tocapture the resulting xml to save file locally.

Thank You.

namespace ResultsWebServicesClient
    public partial class _Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

        private void BindDataToGrid(string CaseNum)
            FG_Results results = new FG_Results();
            DataSet ds1 = new DataSet();
            ds1 = results.Get_FG_Results(CaseNum);
            GridView1.AutoGenerateColumns = true;
            GridView1.DataSource = ds1.Tables[0];

        protected void GetResults(object sender, EventArgs e)


formula to display all combination output


hi all

i am now think of how to get all the output for all the combinations


given : 1234

output = 1234,1243,2143......and so on.....all 24 possible output

if given : 123

output = all 12 output

if given 12345 , all 120 output...

can someone provide me the algorithm or formula for that ?


output cache to be used only when parameter has changed + old question of user control not answered



i have 2 questions about output cache:

1.is it just me , or does it seems that it is used only after the second time that the user reaches the webpage? if so, why, and how can i tweak it to my needs? my guess is that it wouldn't be logical to cache every time a user reach a webpage, but only when it happens enough times.

2.i know that i can use "varybyparam" for using the output cache when the parameter doesn't change , but it seems that it would use the output cache even if there is no parameter , or if the specified paramter is not there. is there a way to overcome this?

3.an old question that somehow marked as "answered" , yet i didn't solve : suppose i created a user control and i gave it values through the CTOR via the aspx file . is it possible to show the values from within the split/design mode? remember that i've talking about ASP.NET and not simply C# winforms . i write this because this question was on :


and the answer that i got was for C# and winforms . i've tried to do the same for ASP.NET , but i've failed.

can anyone please help me?

Use .html method to output asp.net controls


Is it possible to use the .html method to output something like an asp:label ??  It doesn't seem to work for me unless they're standard html controls.  Here's my JQuery:

$(function() {
    $("#btnContinue").click(function() {
    $('#pre_register').html("<div id='post_register'></div>");
    $('#post_register').html("<asp:Label ID='lblUserName' runat='server' Text='Enter your desired user name:'></asp:Label>")
        .fadeIn(2000, function() {

Clear Output Cache


I have set the output cache for 5 pages(5 minutes)

I want to clear  all these pages from cache on some nutton click 

regex: How to allow a comma?

Hi,How to allow a comma?"^ \ $? (\ D (1.3),? (\ D (3 },?)* \ d (3) (\. \ D (0.2))? | \ D (1.3) (\. \ d (0.2))? | \. \ d (1.2 }?)$"  This is works, I need character ","Helpthanks

Regular Expression for Digits, comma & space combination

Hi Can you suggest a Regular Expression for the following category. A text box which should contain: Max size : 53 0-9 digits + a comma + a space The 0-9 numbers should be repeated 5 times and separated by a comma and a space Eg: 123456789, 123456789, 123456789, 123456789, 123456789 Thanks, David.      

Output parameters in OLEDB Command component - SSIS 2008

I have a package that I developed in SSIS 2005 and recently ported to 2008. Everything runs great except an OLE DB Command component that calls a stored procedure that uses output parameters. When I try to run this, I get this error: Error: 0xC0202009 at Data Flow Task, OLE DB Command [100]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Syntax error, permission violation, or other nonspecific error". Error: 0xC004701A at Data Flow Task, SSIS.Pipeline: component "OLE DB Command" (100) failed the pre-execute phase and returned error code 0xC0202009. When I do the same thing in SSIS2005, it works fine. So I setup a new package with 1 data flow. In that data flow, I added a source component, an OLE DB Command, and a destination.  I then tested this with a stored procedure that took no parameters. It worked fine. I then tested it with a stored procedure with 1 parameter defined as OUTPUT. This generated the error.   Is there an issue with output parameters in an OLE DB Command in SSIS 2008?   Thanks!http://bobp1339.blogspot.com
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend