How can I query the database culture (SQL Server 2005)?

这一生的挚爱 提交于 2020-01-04 02:02:13

问题


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...


回答1:


You can find out about the currently configured language using this:

SELECT @@language

and you might also want to check out this:

EXEC sp_helplanguage

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.

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.

The format YYYYMMDD or YYYYMMDD HH:MM:SS will always work, regardless of currently selected language settings in SQL Server.




回答2:


You dont need that.

  • Dates as DATES always get input/ouput in the client, the server culture is irrelevant here as the visualization / string conversion happens on the client. So, use variables foe query parameters and get the proper types as output (should happen autoamtically) and you will not have a problem to start with.
  • If you have to insert strings, use ISO form (2010-12-05 23:15:22.233) which is recognized under ALL culture settings as generic fallback.


来源:https://stackoverflow.com/questions/2432185/how-can-i-query-the-database-culture-sql-server-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!