I have an excel spreadsheet with a customer ID column. I need to take distinct customer IDs from excel and use these values in the filter part of the sql query to determine if any of the IDs are invalid.
Below are the steps that I wish to perform:
- Stored excel data in a datatable ‘dt’
- Connected to the database
- Use Execute Query and pass the unique customer IDs from dt as parameters. Below is the query:
“SELECT column1, column2 FROM tablename where column1 in (@custId)”
- Created 2 parameters:
- Create a separate datatable with only those rows that has a valid customer id ( use the result from the query)
I am stuck on step 3 and the query does not seem to work. How do I pass the customer IDs in the sql statement?
Appreciate your help. Thanks!