G
Guest
Hello all -
I've searched high and low to an answer to my question so I'm posting here as my last option
I'm trying to use the IN keyword in my WHERE clause of the data adapter to gather all IDs, separating them with commas, but I get an error that states that it could not convert a varchar value (due to the potential comma being there I needed to) to an int (which is what the ID field is defined as). Does anybody know what I can do to get around this issue or is there something I'm doing wrong?
Here's my query (@CustIDs can hold a value of 15, for example, or '15,16')
SELECT DISTINCT Customer.CustomerID, Customer.CompanyName, Customer.City + ', ' + Customer.State AS CityState FROM Customer INNER JOIN ClientServicesTable INNER JOIN CompanyServicesTable ON ClientServicesTable.CompanyServiceID = CompanyServicesTable.CompanyServiceID ON Customer.CustomerID = ClientServicesTable.ClientID WHERE (CompanyServicesTable.ServiceType = 'S' OR CompanyServicesTable.ServiceType
= 'B') AND (Customer.CustomerID = @ID OR Customer.CustomerID IN (@CustIDs)) ORDER BY Customer.CompanyNam
Much thanks
Mark
I've searched high and low to an answer to my question so I'm posting here as my last option
I'm trying to use the IN keyword in my WHERE clause of the data adapter to gather all IDs, separating them with commas, but I get an error that states that it could not convert a varchar value (due to the potential comma being there I needed to) to an int (which is what the ID field is defined as). Does anybody know what I can do to get around this issue or is there something I'm doing wrong?
Here's my query (@CustIDs can hold a value of 15, for example, or '15,16')
SELECT DISTINCT Customer.CustomerID, Customer.CompanyName, Customer.City + ', ' + Customer.State AS CityState FROM Customer INNER JOIN ClientServicesTable INNER JOIN CompanyServicesTable ON ClientServicesTable.CompanyServiceID = CompanyServicesTable.CompanyServiceID ON Customer.CustomerID = ClientServicesTable.ClientID WHERE (CompanyServicesTable.ServiceType = 'S' OR CompanyServicesTable.ServiceType
= 'B') AND (Customer.CustomerID = @ID OR Customer.CustomerID IN (@CustIDs)) ORDER BY Customer.CompanyNam
Much thanks
Mark