日期:2014-05-17 浏览次数:20888 次
create function dbo.regexReplace(@str char(11))
RETURNS int
as
begin
DECLARE @result INT
SET @result = 0
IF (LEFT(@str, 3) IN ('130','131','132','133','134','135','136','137','138','139','150','153','156','157','158','159','188','189')
AND PATINDEX('[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]', @str) = 1)
begin
SET @result = 1
end
RETURN @result
end
--楼主测试下:
SELECT dbo.regexReplace('')
SELECT dbo.regexReplace('13312345678')
SELECT dbo.regexReplace('1331234567')
SELECT dbo.regexReplace('13312.45678')