我正在尝试按以下方式过滤查询:
declare @CubeYear as varchar(30)
--Setting it this way so it can later be easily used in SSAS Cubes
set @CubeYear = '[Date].[Year].&[2013]'
SELECT [RankingID]
,[Year]
,[Customer]
,[Rank]
FROM [OBase].[dbo].[fact_KundeRanking]
where '[Date].[Year].&[' + Year + ']' = @CubeYear
但我一直收到以下错误:
将varchar值'[Date]。[Year]。& [2013]'转换为数据类型int时转换失败。
有人知道这可能是什么解决方案吗?
答案 0 :(得分:1)
试试这个 -
where '[Date].[Year].&[' + CAST(Year as varchar(4)) + ']' = @CubeYear