Thursday, March 29, 2012

Does SQL Server handles time zone difference?

Hi
Does SQL Server 200 handles time zone?
We want to transfer all data to another server periodically that is situated
at a different time zone.
Also some time we restore complete database to second server.
we want to keep correct time stored with the data as per the time zone where
second sql server is present.
how can this be achieved?
Regards
Lalit BhatiaHi Lalit
SQL Server is storing the time according to the time that it is
getting from the OS. If you modify the time at the OS level, then SQL
Server will NOT modify the values that it already has in the tables.
Personally I wouldn't want it to do so. I want the data to be
consistent and I wouldn't want it to updates all the records twice a
year because of day light savings.
If you have a requirement to store data in a way that users will see
different time according to the server's time zone, then you can store
the time as UCT time and present it as local time. You can use the
function GETUTCDATE() together with DATEADD() and GETDATE() when ever
you insert, modify or present the data. This way the data at the table
will be the same, but if you move the data to a different server in a
different time zone, then users will see the data that is adjusted to
there time zone. Be aware that this might be confusing. If a person
in N.Y is talking with a person in L.A about one of the records, each
one of them will see a different time.
Lalit wrote:
> Hi
> Does SQL Server 200 handles time zone?
> We want to transfer all data to another server periodically that is situated
> at a different time zone.
> Also some time we restore complete database to second server.
> we want to keep correct time stored with the data as per the time zone where
> second sql server is present.
> how can this be achieved?
>
> Regards
> Lalit Bhatiasql

No comments:

Post a Comment