Is it possible to create a new T-SQL statement using CLR code in SQL Server?

I have a very simple CLR function to do 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);
}

This allows me to write a SQL Like statement.

SELECT * FROM dbo.table1 WHERE dbo.RegexMatch(column1, '[0-9][A-Z]') = 1
-- match entries in col1 like 1A, 2B etc...

I just think it would be nice to reformulate this query so that it can be called as

SELECT * FROM dbo.table1 WHERE column1 REGEXLIKE '[0-9][A-Z]'

Is it possible to create new comparison operators using the CLR code. (I guess from my brief look at the website that the answer is NO , but without harm)

+5
source share
2 answers

, . , , .. - T-SQL. SQL Server 2008R2, .

+6

, SQLCLR: http://msftengprodsamples.codeplex.com/wikipage?title=SS2008!User-Defined%20Data%20Type%20(UDT)%20Sample&referringTitle=Home

:

    public static SqlBoolean operator ==(ComplexNumber c1, ComplexNumber c2)
    {
        return c1.Equals(c2);
    }
0

All Articles