Is it possible to create a new T-SQL Operator using CLR Code in MSSQL?
Posted
by Eoin Campbell
on Stack Overflow
See other posts from Stack Overflow
or by Eoin Campbell
Published on 2010-04-06T08:06:08Z
Indexed on
2010/04/06
8:13 UTC
Read the original article
Hit count: 346
I have a very simple CLR Function for doing Regex Matching
public static SqlBoolean RegExMatch(SqlString input, SqlString pattern)
{
if (input.IsNull || pattern.IsNull)
return SqlBoolean.False;
return Regex.IsMatch(input.Value, pattern.Value, RegexOptions.IgnoreCase);
}
It allows me to write a SQL Statement Like.
SELECT * FROM dbo.table1 WHERE dbo.RegexMatch(column1, '[0-9][A-Z]') = 1
-- match entries in col1 like 1A, 2B etc...
I'm just thinking it would be nice to reformulate that query so it could be called like
SELECT * FROM dbo.table1 WHERE column1 REGEXLIKE '[0-9][A-Z]'
Is it possible to create new comparison operators using CLR Code. (I'm guessing from my brief glance around the web that the answer is NO, but no harm asking)
Thanks, Eoin C
© Stack Overflow or respective owner