DataSet with many OR clauses
I've got a little problem with a query which I create in the Visual Studio Designer.
I need a query with a lot of 'OR'-clauses for the same column.
I found the operator 'IN', but I don't know how to use that in the Visual Studio Designer:
Example IN
:
SELECT EmployeeID, FirstName,开发者_开发技巧 LastName, HireDate, City
FROM Employees
WHERE City IN ('Seattle', 'Tacoma', 'Redmond')
I tried to do it in this way:
SELECT [MachineryId], [ConstructionSiteId], [DateTime],
[Latitude], [Longitude], [HoursCounter]
FROM [PositionData]
WHERE [MachineryID] IN @MachineryIDs
But this doesn't work.
Is there another way to handle a lot of OR
clauses?
Thank you very much for your help.
When doing an IN with a parameter it is used like below, fundamentally the same.
declare @SQL varchar(600)
set @SQL = 'select * from tbl where Cast([MachineryID] as varchar(255)) in ('+ @MachineryIDs +')'
EXEC(@SQL)
精彩评论