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 8501825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:18:55+00:00 2026-06-11T01:18:55+00:00

My webform contain some checkboxes.If perticular checkbox is checked,add column name into select query

  • 0

My webform contain some checkboxes.If perticular checkbox is checked,add column name into select query of sp.Like
Suppose there are 4 checkbox like chklname,chkfname,chkcity,chkmobile.If I check
chklname and chkfname,my query will be :

SELECT LastName,FirstName FROM table1

How to write that in sp?

  • 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-11T01:18:56+00:00Added an answer on June 11, 2026 at 1:18 am
    CREATE PROCEDURE ProcName
        @chklname bit,
        @chkfname bit,
        @chkcity bit,
        @chkmobile bit
    AS
    BEGIN
    SET NOCOUNT ON;
    
        --Only execute the statement if at least one of the checkboxes are set
        if @chklname = 1 or @chkfname = 1 or @chkcity =1 or @chkmobile =1 
            begin
            declare @sqlcommand nvarchar(max) 
    
    
            set @sqlcommand = N'Select '
    
            if @chklname = 1
                set @sqlcommand += N'FirstName '
    
            if @chkfname = 1
            begin
                if len(@sqlcommand) > 1
                    set @sqlcommand += N','
                set @sqlcommand += N'LastName '
            end
            if @chkcity = 1
            begin
                if len(@sqlcommand) > 1
                    set @sqlcommand += N','
                set @sqlcommand += N'City '
            end
            if @chkmobile = 1
            begin
                if len(@sqlcommand) > 1
                    set @sqlcommand += N','
                set @sqlcommand += N'Mobile '
            end
    
            set @sqlcommand += N' FROM table1'
    
            exec sp_executesql @statement = @sqlcommand
    
        end
    END
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble recently. On a WebForm I declare a static object, like
I want submit form with some parameters using httpunit. I wrote smt like WebForm
I have a large webform, and would like to prompt the user to login
I am using the webform module for Drupal 6 and would like to set
I'm reading a blog on how to add MVC functionalities to an existing WebForm
The situation I have an ASP.NET Webform that contains some status information about a
I want to inject a presenter into my webform class. While doing so I
I have created one web-form that contains controls to add name, date of birth,
My ASP.Net webform contains a number of textboxes. I want to add onfocus and
I have a WebForm that contains the following definition for the FCKeditor: <FCKeditorV2:FCKeditor ID=txtBody

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.