Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7715587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:25:24+00:00 2026-06-01T02:25:24+00:00

my table: id address tag 1 test class1 2 test1 class2 3 test3 class3

  • 0

my table:

id address tag
1  test   class1
2  test1  class2
3  test3  class3

In UI i am displaying all tag names as checkboxes.
When user selects one or more tag names then need to get required address values. how to get?
if user selects class1,class2 in UI then need to get test,test1 as result.
Please tell me how to write query in sqlserver 2008 for that.

EDIT CODE :

taglist = "class1,class2";
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
                SqlCommand cmd = new SqlCommand("usp_GetTags", con);
                cmd.Parameters.Add("@Tags", SqlDbType.VarChar).Value = taglist;

                con.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);

while passing the parameters as above not getting any results.if i pass single taglist=class1 getting results.but taglist=”class1,class2″ not getting any resuls.please tell me how to pass multiple parameters from UI.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:25:25+00:00Added an answer on June 1, 2026 at 2:25 am

    You can write the query in sql server by using the IN keyword.

    Select address from mytable where tag IN ('class1','class2')
    

    EDIT:

    Add the parameters with values to the stored procedure like this. The below code is written in C#.net

                comand.Parameters.AddWithValue("@Parameter1", "class1");
                comand.Parameters.AddWithValue("@Parameter2", "class2");
    

    EDIT 2:
    Its very simple to put in a single string all the values, accordingly your query also suits that. Write the query in your stored procedure like

                Select address from mytable where tag IN (@SingleParameter)
    

    and in your coding part write like follow

                string SingleParameter = "";
                SingleParameter = "class1,class2,class3";
                comand.Parameters.AddWithValue("@SingleParameter",SingleParameter);
    

    EDIT 3:
    Finally i found the solution for your problem. Write your stored procedure as below

    ALTER PROCEDURE dbo.TestSP
        /*
        (
        @parameter1 int = 5,
        @parameter2 datatype OUTPUT
        )
        */
        @SingleParameter varchar(30)
    AS
        /* SET NOCOUNT ON */
        declare @tags varchar(500)
        set @tags = @SingleParameter
        create table #t (tag varchar(10))
        set @tags = 'insert #t select ' + replace(@tags, ',', ' union select ')
        exec(@tags)
          Select address from sample1 where (tag in (select tag from #t))
        drop table #t
        RETURN
    

    and also send the parameters SingleParameter as below

                string SingleParameter = "";
                SingleParameter = "'class1','class2','class3'";
                comand.Parameters.AddWithValue("@SingleParameter",SingleParameter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this bit of JavaScript... 15 $('.ajax_edit_address').each(function() { 16 $(this).ajaxForm({ 17 target: $(this).parents('table.address').find('tr.address_header').children(':first'),
table 1(ob): name,address table 2(address): dname,addr I need to update ob.address with address.addr when
My Table: [LocationId] [Address] [ZipCode] When I show a list of Location's, I also
Say I have this table: Person table -------------- PersonId Address table ------------ AddressId PersonAddressId
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Does Ado.net check if the following update is required? ADDRESS table with a TOWN
I have a table with name varchar address varchar country varchar city varchar .....
A location table record has two address id's - mailing and business addressID that
I'm pulling email address records from a table in SQL Server 2005, and want
Using MS - Access 2003 Table S.No Details 1 name 2 address 3 email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.