I have this query:
select * from the table where the column is of type '% firstword [something] secondword [something] thirdword%'
What should I replace [something] with an unknown number of spaces?
Edited to add:% will not work because it matches any character, not just spaces.
Perhaps somewhat optimistic in assuming that the “unknown number” includes zero.
select * from table where REPLACE(column_name,' ','') like '%firstwordsecondwordthirdword%'
The following may help: http://blogs.msdn.com/b/sqlclr/archive/2005/06/29/regex.aspx how it describes the use of regular expressions in SQL queries in SQL Server 2005
I would definitely suggest clearing the input, but this example may work when you call it as a function from the SELECT . Please note that this will potentially be very expensive.
SELECT
http://www.bigresource.com/MS_SQL-Replacing-multiple-spaces-with-a-single-space-9llmmF81.html