1

• 如何列出我使用的每个版本支持的区域 ISO 代码?

我需要检查 ISO 639-1(2 个字符)语言代码以查看它是否受支持。对于 2019 年之前的版本,您不会收到默认回复。它会引发错误。

需求示例:

select format(current_timestamp,'dd-MMMM-yyyy','es')
select format(current_timestamp,'dd-MMMM-yyyy','mn')
select format(current_timestamp,'dd-MMMM-yyyy','ii')
select format(current_timestamp,'dd-MMMM-yyyy','oo')
select format(current_timestamp,'dd-MMMM-yyyy','qq')

以上将在 (my) v.2016 上返回 2 个错误 – 函数调用中提供的文化参数 'oo' 不受支持。不支持函数调用中提供的文化参数“qq”。

这与 sys.syslanguages 中列出的定义不匹配,并且该表也不包括 iso 代码。

谢谢!

4

1 回答 1

0

根据马丁的回答,这因环境而异。丑陋的方法会起作用,但是内部表中的列表会很好。

drop table if exists #SupportedLanguages;
create table #SupportedLanguages(Lang varchar(2));
declare c cursor fast_forward local for
select concat(a.value,b.value)
from string_split('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',',')a
    cross apply string_split('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',',')b
open c;

declare @c varchar(2), @cmd varchar(100);
fetch next from c into @c;

while @@FETCH_STATUS = 0
begin
    select @cmd = concat('select format(current_timestamp,''dd-MMMM-yyyy'',''', @c, ''')')
    begin try
        exec(@cmd);
        insert into #SupportedLanguages values(@c);
    end try
    begin catch
    end catch
    fetch next from c into @c;
end;

close c;
deallocate c;
于 2021-12-25T18:17:31.170 回答