Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Copy data table that contains different Date time types from a DB in one time zone to another DB in different time zone

$
0
0

I have a situation where I have to download subset of data from specific tables and bulk copy them to local SQL server express.

The Server (SQL Server 2008 R2) where I fetch the data from is in one time zone - US Eastern Time Zone (UTC -5)

The SQL server express (SQL Server 2008 express) to which I bulk copy the data is in different time zone - US Mountain Time Zone(UTC - 7)

These are the steps I do

1) Fetch the data in  a dataset (one table data a time). SO the dataset contains only one table's data

2)use SqlBulkCOpy object to write the data from the dataset onto local database.

The following are the ways the SQL server converts the data

1. Columns defined as Date time offset  (DateTimeOFfset Type)

SqlBulkCopy copied the value as it was saved, which is good.

2. Columns defined as DateONly (Date Type)

it copied the value with date set back to previous day. For example if it fetches a data as 2013-06-04, then it is copied as 2013-06-03.  Since Mountain time is 2 hours behind eastern time, it changed to previous day. Why should it do that for Date type?

3. Columns defined as DateTime but the values were saved in UTC time

It copied the value equal to converted local time, So for example if the Date value saved as '2013-06-03 15:03:45' in UTC. I thought it would keep the value since it is UTC, but copied value is changed to '2013-06-03 13:03:45'

4. Columns defined as DateTime but the values were saved in local time

Same as before. But at least this was expected.

So my questions are who is managing the conversion, SQLBulkCopy object or SQL Server itself?

Why the column value whose type is defined as just 'Date', is converted to local time. I thought a column value of Date type would retain the same value. Is it not why we have now a new type 'Date'?

Why couldn't it recognize the value Datetime Column (saved as UTC time) is in UTC and try to copy the same value instead of converting into local? Here I probably I'm missing something.

Any help would be appreciated

Thanks


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>