Amazon RDS - 是否有在 SQL Server 中更改数据库时区的解决方法?

亚马逊最近宣布 支持 Oracle RDS 中的时区更改.

由于 Microsoft SQL Server 2012 仍然不支持此功能,是否有任何解决方法,以获得类似于更改整个数据库时区的功能?

Since this is still not supported for Microsoft SQL Server 2012, are there any workarounds, to obtain functionality similar to changing the whole database time zone?

推荐答案

既然你在寻求解决方法...

Since you're asking for workarounds...

我们基本上完全不考虑服务器时间/数据库时区,完全不使用 UTC.GetUtcDate() 例如对于所有DateCreated"列.由于我们已经致力于采用这种方法,因此我们不会遇到任何问题.

We basically totally disregard server time/database time zone and work entirely off of UTC. GetUtcDate() for instance for all 'DateCreated' columns. Since we've committed to that approach we just don't bump up against any issues.

如果您需要将时区与日期数据一起存储,您可以使用 DateTimeOffset.

If you need to store the time zone alongside your date data, you can use DateTimeOffset.

需要注意的是,维护计划将在服务器时间运行.这不是问题,因为我们在任何日历程序中都将所有内容标准化为本地时间(不是 UTC 时间,也不是服务器时间).

The one caveat is that maintenance plans will be run on server time. This has not been an issue because we normalize everything to local time (which is not UTC and not server time) in any of our calendaring programs.

相关文章