在一个使用SSIS / SSAS的数据仓库项目中,我必须生成自己的时间维度,因为我需要集成个人数据。
我的问题在于SSAS,因为我还需要整合翻译。阅读完文档后,我发现了一个使用SET LANGUAGE ENGLISH
为当前会话设置语言的命令,但我无法更改查询的不同字段的语言。
有没有办法用法语生成MONTH_NAME
并用德语获取MONTH_NAME_DE
?
以下是我在互联网上找到的脚本
WITH Mangal as
(
SELECT Cast ('1870-01-01' as DateTime) Date --Start Date
UNION ALL
SELECT Date + 1
FROM Mangal
WHERE Date + 1 < = '2015-12-31' --End date
)
SELECT
Row_Number() OVER (ORDER BY Date) as ID
, Date as DATE_TIME
, YEAR (date) as YEAR_NB
, MONTH (date) as MONTH_NB
, DAY (date) as DAY_NUMBER
, DateName (mm, date) as MONTH_NAME
, LEFT ( DateName (mm, date), 3) KMONTH_NAME
, DateName (dw, date) as DAY_NAME
, LEFT (DateName (dw, date), 3) as KDAY_NAME
, (SELECT TOP 1 FIELD
FROM TABLEXY
WHERE Date BETWEEN TABLEXY.DATE_FROM AND LEGISLATUR.DATE_TO
AND LANGAGE = 'FR'
) as PERSONAL_FIELD
, (SELECT TOP 1 FIELD
FROM TABLEXY
WHERE Date BETWEEN TABLEXY.DATE_FROM AND LEGISLATUR.DATE_TO
AND LANGAGE = 'DE'
) as PERSONAL_FIELD_DE
FROM Mangal
OPTION (MAXRECURSION 0)
答案 0 :(得分:1)
SQL Server有一个包含月份和工作日名称的表。但是,它们存储为逗号分隔值:
select
months,
shortmonths,
days
from
master.dbo.syslanguages
where
alias in ('English','French', 'German')
您可以在查询中使用此功能。