Sql-Server

在 ssms 上編寫索引時不顯示數據壓縮

  • November 7, 2019

當我右鍵點擊 SSMS 並選擇編寫創建索引的腳本時:

在此處輸入圖像描述

我得到了這個腳本,沒有 data_compression:

USE [APCore]
GO

/****** Object:  Index [i_agencyId]    Script Date: 07/11/2019 12:18:13 ******/
CREATE UNIQUE NONCLUSTERED INDEX [i_agencyId] ON [agy].[agency]
(
   [agencyId] ASC
)
INCLUDE (   [countryCode]) WITH (PAD_INDEX = OFF, 
STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, 
DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, 
ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [NONCLUSTERED_INDEXES]
GO

但是當使用下面的查詢專門檢查數據壓縮時

use APCore
go

SELECT i.name, p.data_compression_desc 
FROM sys.partitions P
INNER JOIN sys.indexes I ON I.object_id = P.object_id AND I.index_id = P.index_id
WHERE P.data_compression > 0 and I.name = 'i_agencyId';

在此處輸入圖像描述

我得到正確的資訊。

我正在使用這個 SSMS

在此處輸入圖像描述

有沒有辦法讓 ssms 在編寫腳本時在索引定義中包含數據壓縮?

確保為數據壓縮正確設置腳本選項

在此處輸入圖像描述

引用自:https://dba.stackexchange.com/questions/252746