I want to update all rows when invoiceID is NULL else update only the rows where all invoiceID‘s are the same.
My current SQL statement is as follows:
UPDATE Table SET strPOnummer = '123'
WHERE strPOnummer = '456' AND strPOnummer != '' AND strPOnummer IS NOT NULL
So, when Table.invoiceID is NULL, it should update all rows, else update only the rows where invoiceID is the same.
Assuming that invoiceID is an input parameter, you could do this:
In this case if the @InvoiceID parameter is not null then the first condition will have to be met as the second will never be met, but if it is null then each row of the table will be matched by the second part of the condition and thus the first one isn’t relevant anymore