笔记193 有关启用或者禁用vardecimal的一些脚本
1 --有关启用或者禁用vardecimal的一些脚本
2 USE master ;
3 GO
4
5 -- Enable vardecimal on database 对数据库开启vardecimal存储格式
6 EXEC sp_db_vardecimal_storage_format 'AdventureWorks', 'ON' ;
7 GO
8
9
10 -- Check the vardecimal storage format state for all databases in the instance 查询当前数据库实例里的所有数据库的vardecimal 的存储格式的状态
11 EXEC sp_db_vardecimal_storage_format
12 GO
13
14 -- Enable vardecimal compression at the table level 允许在表级别开启vardecimal存储格式 的压缩
15 USE AdventureWorks
16 GO
17 -- Note: The BOL example incorrectly references 'decimal data compression'
18 EXEC sp_tableoption 'Sales.SalesOrderDetail', 'vardecimal storage format', 1
19 GO
20
21 -- Does not show vardecimal properties sp_help 命令不会显示vardecimal存储格式
22 EXEC sp_help 'Sales.SalesOrderDetail'
23
24
25 -- So, use the TableHasVarDecimalStorageFormat objectproperty 可以使用objectproperty查看vardecimal存储格式
26 USE AdventureWorks ;
27 GO
28 SELECT name, object_id, type_desc
29 FROM sys.objects
30 WHERE OBJECTPROPERTY(object_id,
31 N'TableHasVarDecimalStorageFormat') = 1 ;
32 GO
33
34 -- Under the covers, this uses sys.dm_db_index_physical_stats to calculate the stats
35 -- Documented in BOL CTP2 as sp_estimatedecimalcompression
36 EXEC sp_estimated_rowsize_reduction_for_vardecimal 'Sales.SalesOrderDetail' ;
37
38 -- Clean-up / disable vardecimal storage format 禁用 vardecimal存储格式
39 USE AdventureWorks
40 GO
41
42 -- Disable table-level storage format 禁用表级别的vardecimal存储格式
43 EXEC sp_tableoption 'Sales.SalesOrderDetail', 'vardecimal storage format', 0
44 GO
45 USE master;
46 GO
47
48
49 -- Disable database property
50 EXEC sp_db_vardecimal_storage_format 'AdventureWorks', 'OFF' ;
51 GO