Just a quick question. I'm using single values manually inputed by the user and doing an SQL query comparing to two columns, like:
SELECT col3,col1,col4 FROM table WHERE
col1='SomeReallyLongText' OR col2='SomeReallyLongText'
The repetition of SomeReallyLongText is tolerable, but my program also supports looping through an Excel document with several hundred rows - which means I'll be doing:
SELECT col3,col1,col4 FROM table WHERE
col1 IN('item1','item2',...'itemN') OR col2 IN('item1','item2',...'itemN')
And the query would be exhaustively long, which I can't imagine is efficient. Is there a way to shorten this so two columns can be compared to the same IN(xxx) set?
If not, are there other (more efficient) ways of giving the set of values in the query?
(I'm using C# with .NET 4.0 Client Profile, using Excel Interop to access the file)
DataTables and stored procedures mssqltips.com/sqlservertip/2112/…