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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:06:07+00:00 2026-06-14T11:06:07+00:00

I have a table that consists of some code-cells (for indexing purposes), and one

  • 0

I have a table that consists of some code-cells (for indexing purposes), and one “value” cell (where the data I am interested in lives), similar to the following:

 column:      datatype:

  code1         int
  code2         int
  code3         int
  code4         int
  attributes    varchar(max)

I am checking against some input codes in the stored procedure that adds to this table, and the constraint for adding is that my INPUT codes (@code1, @code2, @code3, @code4) can either equal some value OR they may be null, but are the same as those in some matching row of the table.

What is the best way to say the following statement:

 SET @targetAttributesCell = (SELECT attributes FROM MyTable
                               WHERE (code1 = @code1)
                                 AND (code2 = @code2)
                                 AND (code3 = @code3)
                                 AND (code4 = @code4)); <-- where code1/@code1 'IS NULL' or = '[some integer]'?

Thanks in advance. Please let me know if I need to be more clear.

  • 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-14T11:06:08+00:00Added an answer on June 14, 2026 at 11:06 am

    Here you go:

    WHERE ISNULL(Code4,SomeInteger)=SomeInteger
    

    If Code4 is null, it’ll match the integer. If Code4 matches the integer, it’ll match the integer. If Code4 is any other integer, it won’t match.

    EDIT

    Do you even need this check? Are there NULL values in your table? If so, then the NULL parameters would just match up.

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

Sidebar

Related Questions

I have a MS access database. In that, one table consists of questions and
I have table that I insert data with following query (from c# code): INSERT
I have a table that consists of comments. Some of them are replies to
We have a SQL Server database table that consists of user id, some numeric
I have an tblEmployeeProfile & a tblPersonnel. tblPersonnel is an HR table, that consists
I have a table that looks like this: id value AGA 0.211 AGA 0.433
I have a table that has a composite key that consists of two int
I have a database with a table that consists of 65k+ entries, which is
Essentially I have some user generated meta data for individual items. Meta data consists
I have a table that consists of two columns: question and answer. I currently

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.