THE SQL Server Blog Spot on the Web
Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | Join | Help

Re: Sql Signature RegEX

  •  06-17-2008, 23:56

    Re: Sql Signature RegEX

    Here is a CLR UDF I prepared for "Inside SQL Server 2005: Query Tuning and Optimization" (which I modified from the version presented in "Inside SQL Server 2005: T-SQL Querying" to better support NULLs):

    [Microsoft.SqlServer.Server.SqlFunction(IsDeterministic=true)]
    public static SqlString sqlsig(SqlString querystring)
    {
    return (SqlString)Regex.Replace(
    querystring.Value,
    @”([\s,(=<>!](?![^\]]+[\]]))(?:(?:(?:(?:(?# expression coming
    )(?:([N])?(')(?:[^']|'')*('))(?# character
    )|(?:0x[\da-fA-F]*)(?# binary
    )|(?:[-+]?(?:(?:[\d]*\.[\d]*|[\d]+)(?# precise number
    )(?:[eE]?[\d]*)))(?# imprecise number
    )|(?:[~]?[-+]?(?:[\d]+))(?# integer
    )|(?:[nN][uU][lL][lL])(?# null
    ))(?:[\s]?[\+\-\*\/\%\&\|\^][\s]?)?)+(?# operators
    )))”,
    @”$1$2$3#$4”);
    }

     

View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement