SQL Server 2012 JOIN SELECT语句返回分区错误

时间:2017-02-17 14:07:45

标签: sql-server join

我正在SQL Server 2012中编写一个select语句,它基于一个列的连接,该列的非数字用于连接。我期待查询做的是删除两个表中的所有非数字,并根据函数返回的数值执行连接。

但是我收到此错误:

  

系统为重复组生成的最大唯一值为   超过分区ID 422228402503680的索引。删除和   重新创建索引可以解决这个问题;否则,使用另一个   聚类密钥。

这是我的问题:

INSERT INTO PP_MLS_BRIDGE
SELECT
      RTPropertyUniqueIdentifier
      ,[FA Unique Listing Identifier - Ref ID]
      ,MLS.[Listing Tracking ID]
      , MLS.[Assessor's Parcel Identification Number] as MLS_PARCELID
      , PP.ParcelID
      , GEOID
      ,'Parcel Match' as MatchType
      ,[Update Timestamp]
  FROM [property].[dbo].[MLS]
  join PROPERTY_PARAMETERS PP on [dbo].udf_extractInteger(PP.ParcelID) = [dbo].udf_extractInteger(MLS.[Assessor's Parcel Identification Number]);

这是dbo.udf_extractInteger()函数:

USE [property]
GO
/****** Object:  UserDefinedFunction [dbo].[udf_extractInteger]    Script Date: 2/17/2017 7:04:29 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 ALTER FUNCTION [dbo].[udf_extractInteger](@string VARCHAR(2000))
    RETURNS VARCHAR(2000)
AS
BEGIN
    DECLARE @count int
    DECLARE @intNumbers VARCHAR(1000)
    SET @count = 0
    SET @intNumbers = ''

    WHILE @count <= LEN(@string)
    BEGIN
        IF SUBSTRING(@string, @count, 1)>='0' and SUBSTRING (@string, @count, 1) <='9'
            BEGIN
                SET @intNumbers = @intNumbers + SUBSTRING (@string, @count, 1)
            END
        SET @count = @count + 1
    END
    RETURN @intNumbers
END

0 个答案:

没有答案