1
獲取房屋或公寓號,我有以下SQL CLR C#UDF:SQL CLR C#用戶定義的函數 - 從地址
141A, Some Street Avenue
4b, St Georges Street
16E Test Avenue
:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Collections;
using System.Text;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString clrFn_GetDigits(string theWord)
{
if (theWord == null) { theWord = ""; }
string newWord = "";
char[] KeepArray = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\\', '/', '-', ' '};
foreach (char thischar in theWord)
{
foreach (char keepchar in KeepArray)
{
if (keepchar == thischar)
{
newWord += thischar;
}
}
}
return (SqlString)(newWord.Trim());
}
}
除了像下面的地址這個偉大的工程,到目前爲止
我想讓我的函數返回141A,4b和16E
任何想法?
您需要一些邏輯來檢查下一個字符 – CR41G14 2013-02-11 10:52:31