0
I have a Procedure and a COMMON TABLE EXPRESSION(subquery). This my CTE does a search and offers to my query the result, my query then uses the results of it.
In my table Address I have a field "Complement" that allows null values. However when my CTE queries and compares with the @add-on if the add-on is empty, the CTE result returns nothing, even though the NULL value exists in the addressee table, otherwise, if you are looking for a record whose complement is filled the search finds.
I’ll show you the code and the error.
Note 1: The error happens because FK does not accept null values and as the subquery returns null value, this error happens. Note 2: The other process after EXEC only registers addresses.