1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SQL queries returning NULL on a few fields but not on all queries

Discussão em 'Outras Linguagens' iniciado por Stack, Abril 4, 2021.

  1. Stack

    Stack Membro Participativo

    In a brief description of the sql tables, one contains "header records" and another "detail line items" related to the first table. The way it was set up is that the key field column in the first table ((TxnID) has its value in each corresponding row in a column in the second table, not a key field.

    In SSMS, I did a series of queries:

    This is the top 1000 rows for the second table. Note the values in the circled columns. [​IMG]

    Then I did a query using the first column value in that same table [​IMG]

    All is good, and the values for the columns matches what I expect.

    Next I did a query using the value of the key column in the first table matching it to the corresponding column in the second table : SELECT * from WHERE = ''


    In this query result, those columns DO NOT show the values from the actual row but instead are NULL.

    I know this has something to do with the query itself because I first discovered this problem in a Power Automate flow that was looking for particular text values in one of those fields but never finding them. When i saw the raw table had the values I was stumped and did these queries to figure out why.

    In the second table, there are no key fields set. The relationship relies on the TxnID value in a row in the first table matching a column in the second table. As a further comment, I neither designed the database nor can it be modified; it is pulled from an application and I have to live with what it is.

    Now that I know where it fails, I am wondering

    a) why it is just those few columns and
    b) how can i get this to work properly?

    Your help greatly appreciated!

    Continue reading...

Compartilhe esta Página