问题描述
如何查询数据库区域性(SQL Server 2005)?
How can I query the database culture (SQL Server 2005) ?
我在插入和获取日期时遇到问题,因为客户端的服务器与我的开发人员服务器运行的文化不同.
I have problems inserting and getting dates, because the client's servers don't run on the same culture as my developer server.
我可以调整日期,但我需要了解服务器的文化...
I can adjust the date, but I need to know the server's culture...
推荐答案
您可以通过以下方式了解当前配置的语言:
You can find out about the currently configured language using this:
SELECT @@language
你可能还想看看这个:
EXEC sp_helplanguage
它将显示可用的语言,以及它们具有的日期格式等.这基本上就是sys.syslanguages
系统目录表的内容.
It will show the available languages, and what date formats etc. they have. This is basically the contents of the sys.syslanguages
system catalog table.
至于日期处理 - 最好使用基于 DateTime 的参数化查询,或者如果您必须有日期字符串,请使用 SQL Server 中的 >ISO-8601 日期格式.
As for date handling - preferably use DateTime based parametrized queries, or if you have to have date strings, use the ISO-8601 date format in SQL Server.
格式 YYYYMMDD
或 YYYYMMDD HH:MM:SS
将始终有效,无论 SQL Server 中当前选择的语言设置如何.
The format YYYYMMDD
or YYYYMMDD HH:MM:SS
will always work, regardless of currently selected language settings in SQL Server.
这篇关于如何查询数据库区域性 (SQL Server 2005)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!