2

在使用 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)
4

1 回答 1

1

SQL Server 有一个包含月份和工作日名称的表。但是,它们存储为逗号分隔值:

select
    months,
    shortmonths,
    days
from
    master.dbo.syslanguages
where
    alias in ('English','French', 'German')

您可以在查询中使用它。

于 2012-06-20T07:39:51.013 回答