Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to use cursor?

Status
Not open for further replies.

sds814

Programmer
Feb 18, 2008
164
US
I have a table with the table name, column name, column values and whether the column values should be included or excluded.

This table is used to filter what data should be loaded. Here is an example

TableName ColumnName ColumnValue Include/Exclude
tblProduct ProductID 1 Exclude
tblProduct ProductID 2 Exclude
tblProduct ProductName Keyboard Include
tblProduct ProductName Mouse Include
tblOrder OrderID 1 Exclude
tblOrder OrderID 2 Exclude
tblOrder OrderName PackageA Exclude
tblOrder OrderName PackageB Exclude

So the queries should be:

DELETE FROM tblProduct WHERE ProductID NOT IN (1,2) AND ProductName IN ('Keyboad','Mouse')

DELETE FROM tblOrder WHERE Order NOT IN (1,2) AND OrderName NOT IN ('PackageA',''PackageB')

Do I have to use a cursor to loop thru each of the column name and filter on the column values?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top