DatabaseProcApplicationCreatedLinks
sybsystemprocssp_dbcc_scale_factor  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** Messages for "sp_dbcc_scale_factor"	
4     */
5     
6     /*
7     ** This procedure takes three parameters
8     ** a size in kilobytes                  (input)
9     ** a scale factor (1024 or 1024 * 1024) (output)
10    ** a display unit, char 'K', 'M', 'G'   (output)
11    **
12    ** The cutoff boundaries are set at
13    ** > 10 G (10485760 k) => G, scale 1024 * 1024
14    ** > 10 M (10240 k) => M, scale 1024
15    ** else K, scale 1
16    **
17    ** Call using
18    **	execute sp_dbcc_scale_factor ,
19    **		@scale_factor = @ output,
20    **		@scale_letter = @ output
21    **
22    ** where name for factor represents ant int
23    ** 	 name for unit represents a char(1)
24    **
25    ** It is installed in sybsystemprocs for use by
26    ** sp_plan_dbccdb and later for use if dbccdb is installed
27    ** by sp_dbcc_evaluatedb.
28    **
29    ** RESOLVE:
30    ** Future Issue:
31    **
32    ** size_in_k is an int.
33    ** int on SQL server is 2^31 max ~ 2 10^9
34    ** hence will not allow us to go past 2 10^12 bytes
35    ** or 2 TB. This can be solved my making the input a
36    ** numeric, in which case callers would also need
37    ** to use a numeric as input value. We will not address this here.
38    */
39    
40    create or replace procedure sp_dbcc_scale_factor
41    (
42        @size_in_k int,
43        @scale_factor int output,
44        @scale_letter char(1) output
45    )
46    as
47        begin
48            if @@trancount = 0
49            begin
50                set chained off
51            end
52    
53            set transaction isolation level 1
54            set nocount on
55            if (@size_in_k > 10485760)
56            begin
57                select @scale_factor = (1024 * 1024)
58                select @scale_letter = 'G'
59            end
60            else
61            begin
62                if (@size_in_k > 10240)
63                begin
64                    select @scale_factor = 1024
65                    select @scale_letter = 'M'
66                end
67                else
68                begin
69                    select @scale_factor = 1
70                    select @scale_letter = 'K'
71                end
72            end
73        end
74    


exec sp_procxmode 'sp_dbcc_scale_factor', 'AnyMode'
go

Grant Execute on sp_dbcc_scale_factor to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_dbcc_scale_factor  
 MUCO 3 Useless Code Useless Brackets in create proc 41
 MUCO 3 Useless Code Useless Begin-End Pair 47
 MUCO 3 Useless Code Useless Brackets 55
 MUCO 3 Useless Code Useless Brackets 57
 MUCO 3 Useless Code Useless Brackets 62
 QISO 3 Set isolation level 53
 MTR1 2 Metrics: Comments Ratio Comments: 60% 40
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 4dec - 1exi + 2 40
 MTR3 2 Metrics: Query Complexity Complexity: 16 40

DEPENDENCIES
CALLERS
called by proc sybsystemprocs..sp_plan_dbccdb