Scott i suspect you posted some code for MYSQL and not SQL Server.
In SQLServer, the best solution is to enable Full Text Indexing, and use that;
for exact word match, but any order, i posted this example a long time ago, which was using dynamic SQL to build a query for search terms; unfortunately, this kind of query isslow, since it requires a table scan. That might be acceptable for small tables, but the more data, the more this would suffer performance wise:
example results:
WHERE CHARINDEX('civil',YOURTABLE.COLUMNNAME) > 0
OR CHARINDEX('war',YOURTABLE.COLUMNNAME) > 0
OR CHARINDEX('memorabilia',YOURTABLE.COLUMNNAME) > 0
OR CHARINDEX('equipment',YOURTABLE.COLUMNNAME) > 0
--better format
DECLARE @SEARCHSTRING VARCHAR(8000),
@ALLSEARCHTERMS VARCHAR(8000),
@SOMESEARCHTERMS VARCHAR(8000),
@COLUMNNAME VARCHAR(128),
@vbCrLf CHAR(2)
SET @SEARCHSTRING='civil war memorabilia equipment'
SET @COLUMNNAME = 'YOURTABLE.COLUMNNAME'
SET @vbCrLf = CHAR(13) + CHAR(10)
SELECT
@ALLSEARCHTERMS = 'WHERE CHARINDEX(''' + REPLACE(@SEARCHSTRING,' ',''',' + @COLUMNNAME + ') > 0 ' + @vbCrLf + ' AND CHARINDEX(''') + ''',' + @COLUMNNAME + ') > 0' + @vbCrLf,
@SOMESEARCHTERMS = 'WHERE CHARINDEX(''' + REPLACE(@SEARCHSTRING,' ',''',' + @COLUMNNAME + ') > 0 ' + @vbCrLf + ' OR CHARINDEX(''') + ''',' + @COLUMNNAME + ') > 0' + @vbCrLf
SELECT @ALLSEARCHTERMS
SELECT @SOMESEARCHTERMS
Lowell