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

  • Home
  • SEARCH
  • 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 6211149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:17:12+00:00 2026-05-24T06:17:12+00:00

I have to write a query to get the following data as result. I

  • 0

I have to write a query to get the following data as result.
I have four columns in my database. ID is not null, all others can have null values.

 EMP_ID    EMP_FIRST_NAME    EMP_LAST_NAME    EMP_PHONE

 1         John              Williams         +123456789 
 2         Rodney                             +124568937
 3                           Jackson          +124578963 
 4         Joyce             Nancy            

Now I have to write a query which returns the columns which are not null.
I do not want to specify the column name in my query.

I mean, I want to use SELECT * FROM TABLE WHERE – and add the filter, but I do not want to specify the column name after the WHERE clause.

This question may be foolish but correct me wherever necessary. I’m new to SQL and working on a project with c# and sql.

Why I do not want to use the column name because, I have more than 250 columns and 1500 rows. Now if I select any row, at least one column will have null value. I want to select the row, but the column which has null values for that particular row should not appear in the result.

Please advice. Thank you in advance.

Regards,
Vinay S

  • 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-05-24T06:17:13+00:00Added an answer on May 24, 2026 at 6:17 am

    Your question reads:

    I want to get all the columns that don’t have a null value.

    And at the same time:

    But I don’t want to specify column names in the WHERE clause.

    These are conflicting goals. Your only option is to use the sys.tables and sys.columns DMVs to build a series of dynamic SQL statements. In the end, this is going to be more work that just writing one query by hand the first time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have a table with the following columns: patient_id, visit_id, and visit_date. How can
I'm trying write a query to find records which don't have a matching record
I have three tables. This query will write down the right answer (x-lines for
How can I determine if I have write permission on a remote machine in
I have to write a component that re-creates SQL Server tables (structure and data)
I have an odd linq subquery issue. Given the following data structure: Parents Children
I have a fairly simple query I'm try to write. If I run the
So im having a problem (obviously). I have the following MySQL table data 7
I have following Scenario: PHP(Server, Writer) ----> MySQL Database <------ PHP(Client, Reader/ Writer); PHPS
I have the following mysql table schema: SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; -- -- Database: `network` --

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.