設定 two digit year cutoff 伺服器組態選項Configure the two digit year cutoff Server Configuration Option

適用於: 是SQL Server 否Azure SQL Database 否Azure SQL 資料倉儲 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

此主題描述如何使用 ,在 SQL Server 2017SQL Server 2017 中設定 SQL Server Management StudioSQL Server Management Studio two digit year cutoff Transact-SQLTransact-SQL伺服器組態選項。This topic describes how to configure the two digit year cutoff server configuration option in SQL Server 2017SQL Server 2017 by using SQL Server Management StudioSQL Server Management Studio or Transact-SQLTransact-SQL. two digit year cutoff 選項會指定從 1753 到 9999 之間的整數,以代表將兩位數年份解譯為四位數年份時的截止年份 (Cutoff Year)。The two digit year cutoff option specifies an integer from 1753 to 9999 that represents the cutoff year for interpreting two-digit years as four-digit years. SQL ServerSQL Server 的預設時間範圍為 1950-2049,代表截止年份為 2049。The default time span for SQL ServerSQL Server is 1950-2049, which represents a cutoff year of 2049. 這表示 SQL ServerSQL Server 會自動把兩位數字年份 49 解譯為 2049,兩位數字年份 50 解譯為 1950,兩位數字年份 99 解譯為 1999。This means that SQL ServerSQL Server interprets a two-digit year of 49 as 2049, a two-digit year of 50 as 1950, and a two-digit year of 99 as 1999. 若要維持回溯相容性,請保留預設值。To maintain backward compatibility, leave the setting at the default value.

本主題內容In This Topic

開始之前Before You Begin

建議Recommendations

  • 此選項是進階選項,只有具經驗的資料庫管理員或通過認證的 SQL ServerSQL Server 專業人員才可變更。This option is an advanced option and should be changed only by an experienced database administrator or certified SQL ServerSQL Server professional.

  • OLE Automation 物件使用 2030 年做為兩位數截止年份。OLE Automation objects use 2030 as the two-digit cutoff year. 您可以使用 two digit year cutoff 選項在 SQL ServerSQL Server 和用戶端應用程式之間提供一致的日期值。You can use the two digit year cutoff option to provide consistency in date values between SQL ServerSQL Server and client applications.

  • 但為避免模稜兩可的日期,請一律在資料中使用四位數的年份。To avoid ambiguity with dates, always use four-digit years in your data.

安全性Security

權限Permissions

不含參數或只含第一個參數之 sp_configure 上的執行權限預設會授與所有使用者。Execute permissions on sp_configure with no parameters or with only the first parameter are granted to all users by default. 以同時設定兩個參數的 sp_configure 來變更組態選項或執行 RECONFIGURE 陳述式時,使用者必須取得 ALTER SETTINGS 伺服器層級權限。To execute sp_configure with both parameters to change a configuration option or to run the RECONFIGURE statement, a user must be granted the ALTER SETTINGS server-level permission. 系統管理員 (sysadmin)serveradmin 固定伺服器角色會隱含 ALTER SETTINGS 權限。The ALTER SETTINGS permission is implicitly held by the sysadmin and serveradmin fixed server roles.

使用 SQL Server Management StudioUsing SQL Server Management Studio

若要設定 two digit year cutoff 選項To configure the two digit year cutoff option

  1. 在物件總管中,請以滑鼠右鍵按一下伺服器,然後選取 [屬性] 。In Object Explorer, right-click a server and select Properties.

  2. 按一下 [其他伺服器設定] 節點。Click the Misc server settings node.

  3. 在 [Two digit year support (兩位數年份支援)] 下的 [當輸入兩位數年份時,解譯為下列之間的年份] 方塊中,輸入或選取一個值作為時間範圍的結束年份。Under Two digit year support, in the When a two digit year is entered, interpret it as a year between box, type or select a value that is the ending year of the time span.

使用 Transact-SQLUsing Transact-SQL

若要設定 two digit year cutoff 選項To configure the two digit year cutoff option

  1. 連接到 Database EngineDatabase EngineConnect to the Database EngineDatabase Engine.

  2. 在標準列中,按一下 [新增查詢]From the Standard bar, click New Query.

  3. 複製下列範例並將其貼到查詢視窗中,然後按一下 [執行]Copy and paste the following example into the query window and click Execute. 此範例示範如何使用 sp_configuretwo digit year cutoff 選項的值設定為 2030This example shows how to use sp_configure to set the value of the two digit year cutoff option to 2030.

USE AdventureWorks2012 ;  
GO  
EXEC sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE ;  
GO  
EXEC sp_configure 'two digit year cutoff', 2030 ;  
GO  
RECONFIGURE;  
GO  
  

如需詳細資訊,請參閱 伺服器設定選項 (SQL Server)伺服器組態選項。For more information, see Server Configuration Options (SQL Server).

後續操作:設定兩位數年份截止選項之後Follow Up: After you configure the two digit year cutoff option

設定會立即生效,不需要重新啟動伺服器。The setting takes effect immediately without restarting the server.

另請參閱See Also

伺服器組態選項 (SQL Server) Server Configuration Options (SQL Server)
sp_configure (Transact-SQL) sp_configure (Transact-SQL)
RECONFIGURE (Transact-SQL)RECONFIGURE (Transact-SQL)