.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

Concatenate ints separated by a comma

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net


I need to add a series of ints in a WHERE clause of a SQL Statement. But before i do that i first need to get the correct int values. I have the following 2 statements:

DECLARE @UID int = 15

FROM	AgentType AT
		INNER JOIN Login L1 ON L.LinkID = L1.ID AND AT.UserID = L1.ID

FROM	AgentType

This returns the following 2 sets of data:

435 425
415 430
425 405
430 410
405 435

View Complete Post

More Related Resource Links

Comma Separated list returned from XML query

I found an example of how to do this, but I must have something wrong as I can't get it to execute without syntax errors or errors. Here's an example XML:   <GrantList> <GRANT SAPGrantNumber="12345" PersonID="168658" SequenceNumber="9" ItemTypeID="1" > <PEOPLE Investigators="Smith, Many" /> <PEOPLE Investigators="Brown, Esmond" /> <PEOPLE Investigators="White, Christine" /> <PEOPLE Investigators="Saga, John" /> <PEOPLE Investigators="Mog, Maureen" /> <PEOPLE Investigators="LastName, FirstName" /> </GRANT> <GRANT SAPGrantNumber="12645" PersonID="168658" SequenceNumber="10" ItemTypeID="1" /> <GRANT SAPGrantNumber="16546" PersonID="168658" SequenceNumber="11" ItemTypeID="1" /> <GRANT SAPGrantNumber="684684351" PersonID="168658" SequenceNumber="12" ItemTypeID="1" > <PEOPLE Investigators="Smith, Many" /> <PEOPLE Investigators="Smith, John" /> <PEOPLE Investigators="Mog, Maureen" /> <PEOPLE Investigators="Xiansa, Ming" /> </GRANT> </GrantList> Here's my query where the xml above is in the

i need the row index value in the form of "comma Separated value"

hi, i am new to the C# in one of my page i need to pass the gridview rowindex vaule where the check box is checked true [i.e in comma sepparated vaule] this is my html code <tr>  <td>  <asp:GridView ID="GridView1" runat="server" EmptyDataText="THERE IS NO DATA FOR THIS REQUEST">  <Columns>  <asp:BoundField DataField="Tablelevelid" HeaderText="att_ID" />  <asp:TemplateField>  <HeaderTemplate>  <asp:CheckBox ID="checkAll" runat="server" onclick="checkAll(this);" /></HeaderTemplate>  <ItemTemplate>  <asp:CheckBox ID="CheckBox1" runat="server" onclick="Check_Click(this)" /></ItemTemplate>  </asp:TemplateField>  <asp:BoundField DataField="NAME" HeaderText="Name" />  <asp:BoundField DataField="PROJECT_ID" HeaderText="Project" />  <asp:TemplateField HeaderText="Comments">  <ItemTemplate>  <asp:TextBox ID="txtComments" runat="server" Text="" MaxLength="250"></asp:TextBox></ItemTemplate>  </asp:TemplateField>  <asp:TemplateField>  <ItemTemplate>  <asp:Require

Split comma separated values into columns




 I have data like this in my table:


AppId   Gender

1         x

2         y

3         x, y

4         x, y, z


I need to transform like this:

AppID          Gender

1                  x

2                  y

3                  x

3                  y

4                  x

4                  y

4                  z


How to do this?


Thanks in advance

Specifying a comma separated string as a parameter value in BIDS


Hi, I have a problem that is driving me mad.  I am trying to create a report in BIDS that pulls data from oracle database and generates the report of call it sales by month.  What I'm attempting to do is to create a parameter in BIDS and force a comma separated value into it and then pass that value into SQL statement for an oracle dataset in other words.

BIDS:  Parameter @QTR Paramater label QTR1  Paramter value ('01','02','03')

           Parameter @Year Parameter label Year Parameter value 2010

Oracle side: select * from ....

where year=:Year and

month in :QTR

Whenever I try to run it like that the report generates but it's blank.  Replacing value in QTR parameter with a single non quoted value like 01 generates report perfectly fine.  Could anyone shed some light as to how properly specify comma delimited strings to be used in :in: statements. 

Binding Text contains "comma separated items" to a checked list box


Stundent record contains a text field, this field contains a comma separated courses that the student have.
I designed a WPF form showing that field and alos a cheched list box showing all available with some items checked according to that text field. here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MicrosoftCourses
  /// <summary>
  /// Interaction logic for MainWindow.xaml

How to list comma separated values in column to multiple rows




I need to list comma seperated values form one to column in multiple rows..ex:

id                           call_rec 

1                            508190,737079,1004618,1075562,1272753,1390841,1544201,2591141

 2                           335395,359380,741049,1113212,2283999,2908851,2001205615 

3                            1212358,2451853,2795175,2001196872 

4                            2283999,2451853 

I want the call_rec for each bug ID to be listed



Need comma separated file name


Hello All,

the output for below query with 3 columns is, here for column "Attachment", I need a comma separater for each attachments. Please help

Output should be, file1.doc,  file2.doc,  file3.doc

UID   SourceSystenName                Attachment

 1              PDI                          file1.doc file2.doc file3.doc

SET @StrXML = '<PDI_Approval_Message>
  <SourceSystem Value="PDI" Name=""></SourceSystem>


Comma-Delimited Output

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.

Need help concatenate varible to a SQL WHERE clause


Hey guys,

I looked over the web and couldn't find much help. Can someone help me with my SELECT statement? What I want to do is concatenate a varible to my WHERE clause. This is what I have:


myDataAdapter = new SqlDataAdapter("SELECT * FROM details WHERE DetailsID = " + lstBoxCategory.SelectedValue.ToString(), connection);


I tried this also but it didn't work:

myDataAdapter = new SqlDataAdapter("SELECT * FROM details WHERE DetailsID = '" + lstBoxCategory.SelectedValue.ToString() + "' ", connection);



How to merge 3 separated color (Red, Green and Blue) saved as grayscale images images into colored i


Hi friends, I have separated Red, Green and Blue color from a bitmap image and stored it in grayscale (obviously).  Now I want to know how can I merge it so that I can get the exact previous colour, when I am merging them by reading its color values but it is giving  me grayscale image :( . Please help me out with some working sample code. Thanking in anticipation.

I am using the following code:

 public bool mergeToRGBandWriteBitmap(string sourceRFile, string sourceGFile, string sourceBFile, string targetFile)
            bool isSuccessfullywritten = false;
                Bitmap bitmapRed = (Bitmap)Image.FromFile(sourceRFile);
                Bitmap bitmapGreen = (Bitmap)Image.FromFile(sourceGFile);
                Bitmap bitmapBlue = (Bitmap)Image.FromFile(sourceBFile);
   Bitmap afterMerge = mergeRGB(bitmapRed, bitmapGreen

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.      

WPF: can we reference a image file (~.png or ~.bmp) from a separated assembly?

We try to reference a image file (xxx.png) in a separated Reference assembly call "ResourceLibrary.dllwe have implement following code in another assembly (not main execuation assembly). <Button > <Image x:Name="pageUpArrow" Stretch="Uniform" Source="pack://application:,,,/ResourcesLibrary;component/Images/xxx.png" /> </Button> We get a complaint at run time:Message="Cannot convert string 'pack://application:,,,/ResourcesLibrary;component/Images/xxx.png' in attribute 'Source' to object of type 'System.Windows.Media.ImageSource'. Cannot locate resource 'images/xxx.png'.  Error at object 'System.Windows.Controls.ControlTemplate' in markup file ...Could we directly reference a image file (xxx.png) in saperated assembly?thanks!Jane

how to concatenate special characters in TSQL ?

hi how can i insert special characters like ' to my select output ?? for example, i tried to get the following output but it just doesnt work.. i am using SQLS2K btw, SELECT ' Hi. this is called the 'modern age' ' note that i need those to ' s with the words modern age :)   thanks in advance :)

How do I keep the previous GridView field value and then concatenate new ones?

Hello all, I have a Timer and a GridView who pulls info from the database every X seconds.Every time I query the database the field 'Comments' is replaced with whatever is on the database  (since it's bound to it).I'd like to keep my previous value and keep adding into my Label the subsequent values queried from the database. For instance, first time I query I get a value of "1" in the Gridview. Now someone changes the database row and next time I queryit I have a value of "2". Well, I would like to concatenate the last value queried with the previous one and so on. So at this point the GridView should show "1" and "2". Here is the piece of code I am talking about: <asp:TemplateField HeaderText="Comments" SortExpression="Comments"> <ItemTemplate>  <asp:Label ID="lblComments" runat="server" Text='<%# Bind("Comments") %>' /> </ItemTemplate></asp:TemplateField> How do I achieve this goal? Thank you!

insert mulitple comma seperated values in a temp table

I have a reporting services report with a single parameter that can take up to 10 numbers which are comma delimited. I need to insert those numbers into a temp table with one column. So if the numbers were 1 - 10 I would expect to see something like this if querying the temp table Acct_Num 1 2 3 4 5 6 7 8 9 10 Is there a way to do this insert into the table using a comma delimeted string of numbers? ThanksFJK

Comma in viewstate string

Hi, I'm running into following error: "The viewstate is invalid for this page and might be corrupted." "Invalid character in base64 string." Only with IE 8.0.  Firefox works fine. The persisted view state is "/wEPDwULLTE2OTU5NzE1MjYPZBYCAgMPZBYCAgEPZBYCAgMPZBYCZg9kFgQCBQ8WAh4FVmFsdWUFCGRpc2FibGVkZAIHDxYCHwAFCGRpc2FibGVkZGSt4I2szqsXGPwfecanpFW+cIZNhQ==,/wEPDwULLTE2OTU5NzE1MjYPZBYCAgMPZBYCAgEPZBYCAgMPZBYCZg9kFgQCBQ8WAh4FVmFsdWUFCGRpc2FibGVkZAIHDxYCHwAFCGRpc2FibGVkZGSt4I2szqsXGPwfecanpFW+cIZNhQ==" i.e. two identical parts separated by a comma. I'm using a form with both jQuery and UpdatePanel. I've inspected the __VIEWSTATE hidden field before the post __doPostBack and  $I.System.InvokePageMethod.  In both cases the viewstate does NOT contain the comma. Any ideas where the field gets doubled up with the comma inserted? Or how to fix.   Thanks,   D
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