There is one tricky scenario. If I am looking for ’40’ in the list ‘17,34,400,12’ then it would find “,40” and return that incorrect entry. This takes care of all solutions:
WHERE (',' + RTRIM(MyColumn) + ',') LIKE '%,' + @search + ',%'
More Related Contents:
- I dont know sql syntax for my table [closed]
- CROSS JOIN vs INNER JOIN in SQL
- Unpivot with column name
- How to generate a range of numbers between two numbers?
- How can I get column names from a table in SQL Server?
- How can I select the first day of a month in SQL?
- SET versus SELECT when assigning variables?
- Multiple INSERT statements vs. single INSERT with multiple VALUES
- Convert varchar into datetime in SQL Server
- Generate Dates between date ranges
- Select statement to find duplicates on certain fields
- How to print VARCHAR(MAX) using Print Statement?
- Check if a row exists, otherwise insert
- T-SQL datetime rounded to nearest minute and nearest hours with using functions
- How to update Identity Column in SQL Server?
- Concatenate values based on ID
- Splitting delimited values in a SQL column into multiple rows
- Script to kill all connections to a database (More than RESTRICTED_USER ROLLBACK)
- TransactSQL to run another TransactSQL script
- Store multiple bit values in a single table column
- Stored procedure that exports data into csv files only exports to one file
- Which SQL query is faster? Filter on Join criteria or Where clause?
- SQL Server equivalent to MySQL enum data type?
- TSQL – How to use GO inside of a BEGIN .. END block?
- Using IF ELSE statement based on Count to execute different Insert statements
- SQL take just the numeric values from a varchar
- Cumulative Total in MS Sql server [duplicate]
- SQL Server SELECT INTO @variable?
- Using CASE Statement inside IN Clause
- SQL Server: +(unary) operator on non-numeric Strings