一个在SSAS中的"The attribute key cannot be found" Error处理方法
来源:互联网 发布:北外英语专业教材知乎 编辑:程序博客网 时间:2024/05/17 01:36
最近在某项目中处理一个维度时却出现了"The attribute key cannot be found"的Error.凭直觉是数据的原因造成的。经过对处理报错的纪录进行分析发现在数据中包含了一些特殊的字符,这些字符是不可见的,通过Unicode函数确定这些字符是Unicode=12288的“类空格”的字符,这样在维度处理时,SQL Server好像认不出它似的(具体什么原因我们也不太清楚),把字段值中Unicode=12288的字符去除后,维度可以处理成功了!这种数据来自录入阶段,因此建议把去除特殊字符的工作放到ETL过程中去。
上图中标识出的纪录是没有处理通过的纪录,标识出的数据就是可疑数据,通过下面的语句确定这个字段的数据确实有"问题",长度和预期的长度(4)不同!
select PrimaryStreetLine2,len(PrimaryStreetLine2) '长度'
from Customer
where CustomerKey = 19903
通过下面的语句确定那些"类空字符"的Unicode
select
substring(PrimaryStreetLine2,4,1) [4Char],
unicode(substring(PrimaryStreetLine2,4,1)) [4Unicode],
substring(PrimaryStreetLine2,5,1) [5Char],
unicode(substring(PrimaryStreetLine2,5,1)) [5Unicode],
substring(PrimaryStreetLine2,15,1) [15Char],
unicode(substring(PrimaryStreetLine2,15,1)) [15Unicode]
from Customer
where CustomerKey = 19903
上面中色彩标识的就是"类空字符"的字符和相应的Unicode,因此想到把它们去除掉后再对维度进行处理。
下面是去除特别字符的SQL 函数:
create function [dm].[ReplaceGivenUnicodeChar](@nstring nvarchar(1000),@unicode int)
returns nvarchar(1000)
as
begin
declare @position int
declare @retstr nvarchar(1000)
declare @nchare nchar(1)
set @retstr = @nstring
set @position = 1
while @position <= len(@nstring)
begin
set @nchare = SUBSTRING(@retstr, @position, 1)
if unicode(@nchare) = @unicode
return replace( @retstr,@nchare,'')
else
set @position = @position + 1
end
return @retstr
end
另解:通过SSIS中的数据流转换组件页中的“字符映射表”组件,将输入字段进行“半角”映射,亦可完成数据清洗,如图:
补充说明:什么时候会发生 这种带有“全角空格(Unicode = 12288)”的数据无法通过cube process?
下面的条件下:
有这样的2条或多条数据,它们中某一字段至少有一条包含Unicode=12288字符的数据,并且这些记录的这个字段除空格或unicode=12288的字符外相同。如表中有这样的2条记录其中一条的PrimaryStreetLine2字段值是“905室xxxx”,'xxxx' 代表Unicode=12288的字符,而另一条数据的PrimaryStreetLine2字段值是“905室”,则这2条数据同时参加cube处理时找不到属性键的错误便发生了。
- 一个在SSAS中的"The attribute key cannot be found" Error处理方法
- SSAS Quick Reference: Attribute Key Cannot Be Found
- Errors in the OLAP Storage Engine: The attribute key cannot be found
- MyEclipse Error: The Table cannot be found on the database
- MyEclipse Error: The Table cannot be found on the database
- Solving the “User cannot be found” error with SPFile.Author
- The page cannot be found
- ”The MathType DLL cannot be found.“问题解决方法
- [ERROR] The service cannot be found for the endpoint reference (EPR) /axis2...
- The Struts dispatcher cannot be found
- The Struts dispatcher cannot be found
- 关于The resource cannot be found.
- The Struts dispatcher cannot be found....
- The Struts dispatcher cannot be found.
- The Struts dispatcher cannot be found
- The Struts dispatcher cannot be found.
- The Struts dispatcher cannot be found
- The Struts dispatcher cannot be found.
- 根据三边长度判断三角形的形状 c语言
- 关于vmware虚拟机下red hat enterprise 5安装vmware tools的备忘
- Python中文问题研究
- CFA与FRM
- 定位
- 一个在SSAS中的"The attribute key cannot be found" Error处理方法
- Idoc 和 bapi 和 rfc 之间的区别
- android平台蓝牙编程
- 斐波那契数列法二
- android平台蓝牙编程
- 用户模式 VS 内核模式(1)
- android平台蓝牙编程
- 用户模式与内核模式(2)
- IDOC 實例