>>>Hi,
>>>
>>>I know I should not be admitting to writing some stupid code. But I was refactoring code in one method where I have the following, in a long SQL Select.
>>>
>>>isnul( table1.table_pk,11) as table1_pk
>>>
>>>Since this is a PK value of a table, it should never be NULL.
>>>But suppose I was being extra cautious, why "11"?
>>>
>>>Please no name calling :)
>>
>>Maybe this is from LEFT join to table1.
>>If it is so you can have NULL values in the query.
>>
>>WHY 11? Only you can tell :-)
>>Maybe 11 is impossible value and that way you recognize these records?
>>
>>The example is from VFP but it is valid to TSQL too
>>
>>CREATE CURSOR Tbl1 (Fld1 int, Fld2 char(2))
>>INSERT INTO Tbl1 (Fld1, Fld2) VALUES (1, [aa])
>>INSERT INTO Tbl1 (Fld1, Fld2) VALUES (2, [bb])
>>
>>CREATE CURSOR Tbl2 (Fld1 int, Fld2 char(2))
>>INSERT INTO Tbl2 (Fld1, Fld2) VALUES (1, [cc])
>>INSERT INTO Tbl2 (Fld1, Fld2) VALUES (2, [dd])
>>INSERT INTO Tbl2 (Fld1, Fld2) VALUES (3, [ee])
>>
>>SELECT Tbl2.*,;
>> NVL(Tbl1.Fld1, 11) AS Tbl1Fld1;
>>FROM Tbl2;
>>LEFT JOIN Tbl1 ON Tbl2.Fld1 = Tbl1.Fld1
>>
>
>Your point about the LEFT join makes sense. The SQL Select does have a LEFT joint of the same table. Which I am trying to eliminate. And I will check the code, down from this SQL Select, if the value 11 is being considered anywhere (as possible).
>Thank you!
Considering that, I have some tables with fixed, predefined PK's that are used in special cases. Something like that? What is the record with PK 11?
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]