using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; using System.Text.RegularExpressions; namespace CLRPlay { public partial class UserDefinedFunctions { static readonly Regex _regex = new Regex(@"[^0-9]*", RegexOptions.Compiled); static readonly string _nR = @""; [Microsoft.SqlServer.Server.SqlFunction] public static SqlString Indexkey(SqlString val) { if (val.IsNull) return SqlString.Null; return _regex.Replace(val.ToString(), _nR); } }; }