samuelbrody1249
samuelbrody1249

Reputation: 4767

SQL Server regex alternation

What would be the proper format for the following regular expression in SQL Server?

select top 100 * 
from posts
where tags like '(c++)|(performance)'

Upvotes: 0

Views: 263

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521194

SQL Server does not support formal regex, so you will have to use LIKE here:

SELECT TOP 100 *
FROM posts
WHERE tags LIKE '%c++%' OR tags LIKE '%performance%';

Note: If the tags column really stores one tag per record, then just use equality checks:

SELECT TOP 100 *
FROM posts
WHERE tags IN ('%c++', 'performance');

Upvotes: 2

Related Questions