Skip to content
Advertisement

Exclude specific rows from table in Stored Procedure

I have a table named Blacklist and table named Order.

Both have CustomerId column.

Stored Procedure ExecOrder manipulates Order table.

My goal is to exclude Orders that have Blacklisted CustomerId (meaning : Order’s CustomerId is in Blacklist table).

I edited ExecOrder SP like this:

@Temp table returns correct list of CustomerIds. Problem is that blacklisted orders are not excluded.

Advertisement

Answer

Your @Temp table is holding blacklisted customers.

Now, you need to select orders of customers not existing in @Temp table.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement