В августе 2005 г. Congress санкций передан Акт политики энергии. Эта процедура изменяет дату начала и Дата окончания летнего времени (DST). Когда этот процесс переходит в силу в 2007 г., летнего времени будет запущен ранее три недели и заканчивается одна неделя, позже его традиционно запуска и завершено. В частности летнего времени начнется в 2: 00 второе воскресенье марта в и заканчивается в 2: 00 в первое воскресенье ноября.
В следующей таблице перечислены изменения на летнее время в 2007 г.
Свернуть эту таблицуРазвернуть эту таблицу
| Дата ранее начала летнего времени | Дата начала периода летнего времени в 2007 г. | Дата, когда ранее окончания периода летнего времени | Дата окончания периода летнего времени в 2007 г. |
|---|
| Первое воскресенье апреля | Второе воскресенье марта в | Последнее воскресенье октября | Первое воскресенье ноября |
| Было бы 1 апреля 2007 г. | 11 Марта 2007 г. | Было бы 28 октября 2007 г. | 4 Ноября 2007 г. |
В данной статье рассматривается подготовка Microsoft SQL Server 2005 и SQL Server 2000 для изменения периода летнего времени в 2007 г.
Действия, которые необходимо выполнить
Если SQL Server, установленных на компьютере, который настроен на автоматическую настройку летнего времени и часового пояса компьютера следует изменения периода летнего времени в 2007 г., необходимо выполнить следующие действия.
- Установите обновление для Windows, описанного в статье Microsoft Knowledge Base 924840.Для получения дополнительных сведений обратитесь к следующей статье Базы Знаний Майкрософт::
924840
(http://support.microsoft.com/kb/924840/
)
Проверка версии обновления 2007 глобальной часового пояса для Windows
- Если SQL Server Notification Services, установленных на компьютере, установите обновление, описанное в статье Microsoft Knowledge Base 931815.Для получения дополнительных сведений обратитесь к следующей статье Базы Знаний Майкрософт::
931815
(http://support.microsoft.com/kb/931815/
)
обновление 2007 часового пояса для служб уведомления SQL Server 2005 и служб уведомления SQL Server 2000
- Нет необходимости применения любого обновления для SQL Server, чтобы убедиться в правильности работы SQL Server. Тем не менее необходимо обновить операционную систему. Кроме того необходимо обновить продукты и приложения, взаимодействующие с SQL Server. Эти продукты и приложения могут включать служб Notification Services, службы Windows SharePoint Services Microsoft CRM и так далее. Полный список обновлений, которые необходимо применить для других продуктов корпорации Майкрософт посетите следующий веб-узел корпорации Майкрософт:
Время использования SQL Server и отчетность
В SQL Server 2005 и SQL Server 2000 ядро СУБД SQL Server использует два вида таймера для создания сведений о времени:
- Таймер высокого разрешения
- Таймер с низким разрешением
Таймер высокого разрешения разрешение таймера на основе инструкции процессора RDTSC (чтение штамп времени счетчика). В таймер с низким разрешением, на основе разрешение таймера
GetTickCountфункция в Microsoft Windows API.
Различные основе таймера фоновых задач и важных системных компонентов используют эти таймеры для их правильной работы. Поскольку эти таймеры работать как относительные величины в определенное время, внутренних компонентов и внутренних операций не повлияет изменения периода летнего времени в 2007 г.
For example, you perform tasks that involve the following timer-based activities or timer-based components:
- System components such as lazy writer, lock monitor, and scheduler monitor
- Background tasks such as ghost cleanup and auto-shrink
- Time-out-based resources such as locks and latches
- Scheduled activities such as SQL Server Agent jobs and maintenance plans
- System statements such as theWAITFORstatement
SQL Server also generates time information that is made available to external components and applications. This time information is retrieved from the Windows operating system. Therefore, the time information is accurate as long as the operating system returns the correct time value.
For example, you perform tasks that involve the following external components and applications:
- SQL Server Profiler or SQL Profiler event columns such as theStart Timecolumn, theEnd Timecolumn, and theDurationcolumn for various events
- Time information that is reported in various logs such as the SQL Server Errorlog, event logs, and system tables
- System functions such as theGetDateфункция иGetUtcDatefunction:
Рассмотрим описанную ниже ситуацию.. You create a SQL Server trace by using SQL Server Profiler or SQL Profiler. The trace records a query that starts before the March 2007 DST time change and finishes after the March 2007 DST time change. In this scenario, the time information is accurate and is not affected by the DST changes.
The following is the sample output of the trace:
EventSequence EventClass TextData StartTime EndTime Duration
156 Sql:StmtStarting Select * From Table1 2007-03-11 01:59:57.187
157 Sql:StmtCompleted Select * From Table1 2007-03-11 01:59:57.187 2007-03-11 03:00:07.187 9987
Similarly, the following is the sample output of a trace that records a query during the November 2007 DST time change:
EventSequence EventClass TextData StartTime EndTime Duration
178 Sql:StmtStarting Select * From Table1 2007-11-04 01:59:54.967
179 Sql:StmtCompleted Select * From Table1 2007-11-04 01:59:54.967 2007-11-04 01:00:05.030 10055
Known DST-related SQL Server issues that are not specific to the changes to DST in 2007
DateDiff and DateAdd date and time functions are not DST aware
When you use Transact-SQL statements to perform time calculations that are based on system-provided date and time functions, you must carefully investigate the statements. Specifically, if you have written DST times in hard code in the application logic, the
DateDiffи
DateAddsystem functions are not DST aware.
For example, an application runs the following statements to calculate the time difference. The calculation is based on the old DST time. Notice that under the new DST system in 2007, 2007-03-11 is the starting date of DST. However, under the old DST system, 2007-04-01 would be the starting date of DST.
DECLARE @starttime datetime
DECLARE @endtime datetime
SELECT @starttime = GetDate() -- returns '2007-03-11 1:59:50.000'
WAITFOR DELAY '00:00:30'
SELECT @endtime = GetDate() –- returns '2007-03-11 3:00:20.000'
If @starttime < '2007-04-01 3:00:00.000' And
@endtime > '2007-04-01 1:59:59.000'
SELECT (cast((DATEDIFF(s, @starttime, @endtime)) as int) - 3600) AS TimeDiffInSecs
Else
SELECT cast((DATEDIFF(s, @starttime, @endtime)) as int) AS TimeDiffInSecs
Go
When you run the statements, you receive the following result:
TimeDiffInSecs
--------------
3,630
Поскольку
DateDiffsystem function is not DST aware, the statements return 3,630 seconds instead of 30 seconds.
To correct the time calculation in such scenarios, use the
GetUtcDatefunction instead of the
GetDatefunction:. надписью
GetUtcDatefunction returns the current UTC time. The current UTC time is derived from the current local time together with the time zone setting in the operating system of the computer on which SQL Server is running.
The following are modified statements that work correctly:
/*-------------------------------------------------------
GetDate() GetUtcDate()
datetime 2007-03-11 1:59:50.000 2007-03-11 09:59:50.000
datetime 2007-03-11 3:00:20.000 2007-03-11 10:00:20.000
-------------------------------------------------------*/
DECLARE @starttime datetime
DECLARE @endtime datetime
SELECT @starttime = GetUtcDate() -- returns '2007-03-11 9:59:50.000'
WAITFOR DELAY '00:00:30'
SELECT @endtime = GetUtcDate() –- returns '2007-03-11 10:00:20.000'
SELECT DATEDIFF (s, @starttime, @endtime) AS TimeDiffInSecs
Go
When you run the statements, you receive the correct result as follows:
TimeDiffInSecs
--------------
30
Effect of the DST end date on scheduled SQL Server Agent jobs
Рассмотрим описанную ниже ситуацию.. You have a scheduled SQL Server Agent job that prints current local time. The job runs every 15 minutes. When the DST change occurs in November 2007, SQL Server Agent automatically tracks the DST change. SQL Server Agent bases its tracking on the operating system and updates the next scheduled run of the job correctly.
The following is the sample output of the job:
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-03-11 01:30:00
CurrentTime 2007-03-11 01:30:00.343
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-03-11 01:45:00
CurrentTime 2007-03-11 01:45:00.343
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-03-11 03:00:00
CurrentTime 2007-03-11 03:00:00.357
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-03-11 03:15:00
CurrentTime 2007-03-11 03:15:00.357
In this example, there is a one-hour gap between the run of the job at 2007-03-11 02:00:00 and the run of the job at 2007-03-11 03:00:00 as expected.
However, there is a known issue in which scheduled SQL Server Agent jobs cannot run for one hour during the period when the November 2007 DST change occurs. After the clock is changed back from 2:00 A.M. to 1:00 A.M. on November 4, 2007, SQL Server Agent jobs would skip the next hour and wait until 2:00 A.M. to start next run. This is a known issue. This issue occurred even under the pre-2007 DST conventions. This issue does not result from the changes to DST in 2007.
The following is the sample output of the job:
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-11-04 01:30:00
CurrentTime 2007-11-04 01:30:00.343
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-11-04 01:45:00
CurrentTime 2007-11-04 01:45:00.343
one hour plus 15 minutes gap here */
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-11-04 02:00:00
CurrentTime 2007-11-04 02:00:00.357
Job 'Daylight Savings Job 1' : Step 1, 'step 1' : Began Executing 2007-11-04 02:15:00
CurrentTime 2007-11-04 02:15:00.357
Notice that in the sample output of the job, there is a one-hour-and-15-minute gap between the run of the job at 2007-11-04 01:45:00 and the run of the job at 2007-11-04 02:00:00. This behavior could affect the replication agent jobs, the backup jobs, log shipping jobs, and other scheduled jobs in SQL Server.