DatabaseProcApplicationCreatedLinks
sybsystemprocssp_spaceusage_showhelp_display  31 Aug 14Defects Dependencies

1     
2     /*
3     ** Generated by spgenmsgs.pl on Tue Oct 31 23:35:59 2006 
4     */
5     /*
6     ** raiserror Messages for spaceusage_showhelp [Total 1]
7     **
8     ** 19194, "Argument '%1!' is either invalid or non-unique. Valid arguments are: %2!"
9     */
10    /*
11    ** sp_getmessage Messages for spaceusage_showhelp [Total 35]
12    **
13    ** 18954, "Usage:"
14    ** 19539, "For more information, use:"
15    ** 19540, "For entity '%1!':"
16    ** 19541, "Examples:"
17    ** 19542, "%1!Display %2!information in '%3!' for"
18    ** 19543, "%1!Display %2!information in '%3!' for any index starting with '%4!' on"
19    ** 19544, "%1!Display summary information in '%2!' for table '%3!' owned by you"
20    ** 19545, "%1!Display summary information in '%2!' for all index on table '%3!' owned by you"
21    ** 19546, "%1!any table starting with '%2!' owned by %3!"
22    ** 19547, "%1!Run '%2!' on each."
23    ** 19548, "%1!where %2!"
24    ** 19549, "%1!where %2!%3!ordered by %4! descending"
25    ** 19550, "%1!any table starting with '%2!' owned by anyone"
26    ** 19551, "%1!Report %2!information in '%3!' for"
27    ** 19552, "%1!Report %2!information in '%3!' for any index starting with '%4!' on"
28    ** 19553, "%1!from archive table '%2!' in current database"
29    ** 19554, "%1!from archive table '%2!' in '%3!' database"
30    ** 19555, "%1!and dated between '%2!' and %3!"
31    ** 19556, "%1!and dated before %2!"
32    ** 19557, "%1!Report summary information in '%2!' for table '%3!' owned by you"
33    ** 19558, "%1!Report summary information in '%2!' for all index on table '%3!' owned by you"
34    ** 19559, "%1!Archive %2!information in '%3!' for"
35    ** 19560, "%1!Archive %2!information in '%3!' for any index starting with '%4!' on"
36    ** 19561, "%1!into table '%2!' in current database"
37    ** 19562, "%1!into table '%2!' in '%3!' database"
38    ** 19563, "%1!Print usage help on the display action"
39    ** 19564, "%1!Print usage help on the report action for the index entity"
40    ** 19565, "The USING clause can be used with the action keyword (except 'help') as follows:"
41    ** 19566, "%1!for 'display' and 'display summary' action"
42    ** 19567, "%1!for 'archive', 'report' and 'report summary' action"
43    ** 19589, "Display the space usage information for an entity in the current database."
44    ** 19590, "Report from an archive table the space usage information for an entity in the current database."
45    ** 19591, "Archive into an archive table the space usage information for an entity in the current database."
46    ** 19592, "The USING clause may be used to specify the unit, the archive database name, and the prefix string for the archive table."
47    ** 19593, "By default, unit is assumed 'KB', current database is the archive database and no prefix string is assumed."
48    */
49    /*
50    ** End spgenmsgs.pl output.
51    */
52    /*
53    **	SP_SPACEUSAGE_SHOWHELP_DISPLAY
54    **
55    **	The sub-procedure to print "display" action specific help/usage 
56    **	information for the sp_spaceusage procedure. Called by sp_spaceusage.
57    **
58    **	Parameters
59    **		@helpentity	- Entity type on which help is sought.
60    **		@verbose	- Information mode is verbose or terse.
61    **
62    **	Returns 
63    **		0 - always. Prints the usage information or error messge for
64    **		    invalid action/entity.
65    {
66    */
67    create procedure sp_spaceusage_showhelp_display
68    (
69        @helpentity varchar(12)
70        , @verbose bit
71    )
72    as
73        begin -- {
74    
75            declare @pattern varchar(50)
76                , @pattern4table varchar(50)
77                , @pattern4index varchar(50)
78                , @msg varchar(256)
79    
80            select @helpentity = lower(ltrim(rtrim(@helpentity)))
81                , @pattern4index = "nc%"
82                , @pattern4table = "my%"
83    
84            if @helpentity is NULL
85                or @helpentity not in ("index", "table", "tranlog")
86                or @verbose = 1
87    
88            begin -- {
89    
90                exec sp_getmessage 19589, @msg out
91                print @msg
92                print ""
93    
94                exec sp_getmessage 18954, @msg output
95                print @msg
96    
97                print "sp_spaceusage 'display', {'table'|'index'}, <name>"
98                print "			[,<select_list> [,<where_clause> [,<order_by> [,<command>]]]]"
99                print ""
100               print "sp_spaceusage 'display summary', {'table'|'index'}, <name>"
101               print "			[,<where_clause> [,<order_by> [,<command>]]]"
102               print ""
103               print "sp_spaceusage 'display', 'tranlog' [,{'syslogs'|NULL}"
104               print "			[,<select_list> [,<where_clause> [,<order_by>]]]]"
105               print ""
106   
107               exec sp_getmessage 19539, @msg out
108               print @msg
109   
110               print "sp_spaceusage 'help', 'display', 'table'"
111               print "sp_spaceusage 'help', 'display', 'index'"
112               print "sp_spaceusage 'help', 'display', 'tranlog'"
113               print ""
114               print ""
115   
116           end -- }
117   
118           select @pattern = case @helpentity
119                   when "index"
120                   then @pattern4table + "." + @pattern4index
121                   else @pattern4table
122               end
123   
124           if @helpentity in ("table", "index")
125           begin -- {
126   
127               exec sp_getmessage 19540, @msg out
128               print @msg, @helpentity
129   
130               exec sp_getmessage 18954, @msg output
131               print @msg
132   
133               print "sp_spaceusage 'display [using unit=<unit>]', '%1!', <name>"
134                   , @helpentity
135               print "		[,<select_list> [,<where_clause> [,<order_by> [,<command>]]]]"
136               print ""
137               print "sp_spaceusage 'display summary [using unit=<unit>]', '%1!', <name>"
138                   , @helpentity
139               print "		[,<where_clause> [,<order_by> [,command]]]"
140               print ""
141   
142               exec sp_getmessage 19541, @msg out
143               print @msg
144               print ""
145   
146               if @helpentity = "table"
147               begin
148                   exec sp_getmessage 19542, @msg out
149               end
150               else
151               begin
152                   exec sp_getmessage 19543, @msg out
153               end
154               print @msg, "  -- ", NULL, "KB", "nc"
155   
156               exec sp_getmessage 19546, @msg out
157               print @msg, "  -- ", "my", "'user1'"
158   
159               print "  -- "
160               print "  sp_spaceusage 'display', '%1!', 'user1.%2!'"
161                   , @helpentity
162                   , @pattern
163   
164               print ""
165   
166               if @helpentity = "table"
167               begin
168                   exec sp_getmessage 19542, @msg out
169               end
170               else
171               begin
172                   exec sp_getmessage 19543, @msg out
173               end
174               print @msg, "  -- ", NULL, "MB", "nc"
175   
176               exec sp_getmessage 19546, @msg out
177               print @msg, "  -- ", "my", "'user1'"
178   
179               exec sp_getmessage 19547, @msg out
180               print @msg, "  -- ", "update table statistics"
181   
182               print "  -- "
183               print "  sp_spaceusage 'display using unit=MB', '%1!', 'user1.%2!', NULL, NULL, NULL,"
184                   , @helpentity, @pattern
185               print "		 'update table statistics'"
186   
187               print ""
188   
189               if @helpentity = "table"
190               begin
191                   exec sp_getmessage 19542, @msg out
192               end
193               else
194               begin
195                   exec sp_getmessage 19543, @msg out
196               end
197               print @msg, "  -- ", "ALL ", "pages", "nc"
198   
199               exec sp_getmessage 19546, @msg out
200               print @msg, "  -- ", "my", "'dbo'"
201   
202               exec sp_getmessage 19549, @msg out
203               print @msg, "  -- ", "PctBloatRsvdPages > 40", ", "
204                   , "PctBloatRsvdPages"
205   
206               print "  -- "
207               print "  sp_spaceusage 'display using unit=pages', '%1!', 'dbo.%2!', '*',"
208                   , @helpentity, @pattern
209               print "		 'where PctBloatRsvdPages > 40','order by PctBloatRsvdPages desc'"
210   
211               print ""
212   
213               if @helpentity = "table"
214               begin
215                   exec sp_getmessage 19542, @msg out
216               end
217               else
218               begin
219                   exec sp_getmessage 19543, @msg out
220               end
221               print @msg, "  -- ", "'Id, IndId, PtnId, PctBloatRsvdPages' "
222                   , "KB", "nc"
223   
224               exec sp_getmessage 19550, @msg out
225               print @msg, "  -- ", "my"
226   
227               exec sp_getmessage 19548, @msg out
228               print @msg, "  -- ", "PctBloatRsvdPages > 40"
229   
230               select @pattern = "%." + @pattern
231   
232               print "  -- "
233               print "  sp_spaceusage 'display using unit=KB', '%1!', '%2!',"
234                   , @helpentity, @pattern
235               print "		 'Id,IndId,PtnId,PctBloatRsvdPages', 'where PctBloatRsvdPages > 40'"
236   
237               print ""
238   
239               select @pattern = case @helpentity
240                       when "index"
241                       then "mytable.%"
242                       else "mytable"
243                   end
244   
245               if @helpentity = "table"
246               begin
247                   exec sp_getmessage 19544, @msg out
248               end
249               else
250               begin
251                   exec sp_getmessage 19545, @msg out
252               end
253               print @msg, "  -- ", "KB", "mytable"
254   
255               exec sp_getmessage 19549, @msg out
256               print @msg, "  -- ", "PctBloatRsvdPages > 40", ", "
257                   , "PctBloatRsvdPages"
258   
259               print "  -- "
260               print "  sp_spaceusage 'display summary', '%1!', '%2!',"
261                   , @helpentity, @pattern
262               print "		 'where PctBloatRsvdPages > 40', 'order by PctBloatRsvdPages desc'"
263   
264               print ""
265   
266           end -- }
267           else if @helpentity = "tranlog"
268           begin -- {
269   
270               exec sp_getmessage 19540, @msg out
271               print @msg, @helpentity
272   
273               exec sp_getmessage 18954, @msg output
274               print @msg
275   
276               print "sp_spaceusage 'display [using unit=<unit>]', 'tranlog' [,{'syslogs'|NULL}"
277               print "		[,<select_list> [,<where_clause> [,<order_by>]]]]"
278               print ""
279   
280               exec sp_getmessage 19541, @msg out
281               print @msg
282               print ""
283   
284               exec sp_getmessage 19542, @msg out
285               select @msg = @msg + " transaction log"
286               print @msg, "  -- ", NULL, "KB"
287   
288               print "  -- "
289               print "  sp_spaceusage 'display', 'tranlog', 'syslogs'"
290               print ""
291   
292               exec sp_getmessage 19542, @msg out
293               select @msg = @msg + " transaction log"
294               print @msg, "  -- ", "ALL ", "pages"
295   
296               exec sp_getmessage 19549, @msg out
297               print @msg, "  -- ", "IsLogFull = 1", ", "
298                   , "TotalPages"
299   
300               print "  -- "
301               print "  sp_spaceusage 'display using unit=pages', 'tranlog', NULL, '*',"
302               print "		 'where IsLogFull = 1','order by TotalPages desc'"
303   
304               print ""
305   
306               exec sp_getmessage 19542, @msg out
307               select @msg = @msg + " transaction log"
308               print @msg, "  -- ", "'DBName, Id, TotalPages, UsedPages, FreePages' "
309                   , "MB"
310   
311               exec sp_getmessage 19548, @msg out
312               print @msg, "  -- ", "TotalPages > 2"
313   
314               print "  -- "
315               print "  sp_spaceusage 'display using unit=MB', 'tranlog', NULL,"
316               print "		 'DBName,Id,TotalPages,UsedPages,FreePages', 'where TotalPages > 2'"
317   
318               print ""
319   
320           end -- }
321   
322           return (0)
323   
324       end -- }	-- }
325   


exec sp_procxmode 'sp_spaceusage_showhelp_display', 'AnyMode'
go

Grant Execute on sp_spaceusage_showhelp_display to public
go
DEFECTS
 MEST 4 Empty String will be replaced by Single Space 92
 MEST 4 Empty String will be replaced by Single Space 99
 MEST 4 Empty String will be replaced by Single Space 102
 MEST 4 Empty String will be replaced by Single Space 105
 MEST 4 Empty String will be replaced by Single Space 113
 MEST 4 Empty String will be replaced by Single Space 114
 MEST 4 Empty String will be replaced by Single Space 136
 MEST 4 Empty String will be replaced by Single Space 140
 MEST 4 Empty String will be replaced by Single Space 144
 MEST 4 Empty String will be replaced by Single Space 164
 MEST 4 Empty String will be replaced by Single Space 187
 MEST 4 Empty String will be replaced by Single Space 211
 MEST 4 Empty String will be replaced by Single Space 237
 MEST 4 Empty String will be replaced by Single Space 264
 MEST 4 Empty String will be replaced by Single Space 278
 MEST 4 Empty String will be replaced by Single Space 282
 MEST 4 Empty String will be replaced by Single Space 290
 MEST 4 Empty String will be replaced by Single Space 304
 MEST 4 Empty String will be replaced by Single Space 318
 MGTP 3 Grant to public sybsystemprocs..sp_spaceusage_showhelp_display  
 MNER 3 No Error Check should check return value of exec 90
 MNER 3 No Error Check should check return value of exec 94
 MNER 3 No Error Check should check return value of exec 107
 MNER 3 No Error Check should check return value of exec 127
 MNER 3 No Error Check should check return value of exec 130
 MNER 3 No Error Check should check return value of exec 142
 MNER 3 No Error Check should check return value of exec 148
 MNER 3 No Error Check should check return value of exec 152
 MNER 3 No Error Check should check return value of exec 156
 MNER 3 No Error Check should check return value of exec 168
 MNER 3 No Error Check should check return value of exec 172
 MNER 3 No Error Check should check return value of exec 176
 MNER 3 No Error Check should check return value of exec 179
 MNER 3 No Error Check should check return value of exec 191
 MNER 3 No Error Check should check return value of exec 195
 MNER 3 No Error Check should check return value of exec 199
 MNER 3 No Error Check should check return value of exec 202
 MNER 3 No Error Check should check return value of exec 215
 MNER 3 No Error Check should check return value of exec 219
 MNER 3 No Error Check should check return value of exec 224
 MNER 3 No Error Check should check return value of exec 227
 MNER 3 No Error Check should check return value of exec 247
 MNER 3 No Error Check should check return value of exec 251
 MNER 3 No Error Check should check return value of exec 255
 MNER 3 No Error Check should check return value of exec 270
 MNER 3 No Error Check should check return value of exec 273
 MNER 3 No Error Check should check return value of exec 280
 MNER 3 No Error Check should check return value of exec 284
 MNER 3 No Error Check should check return value of exec 292
 MNER 3 No Error Check should check return value of exec 296
 MNER 3 No Error Check should check return value of exec 306
 MNER 3 No Error Check should check return value of exec 311
 MUCO 3 Useless Code Useless Brackets in create proc 68
 MUCO 3 Useless Code Useless Begin-End Pair 73
 MUCO 3 Useless Code Useless Brackets 322
 MTR1 2 Metrics: Comments Ratio Comments: 32% 67
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 11 = 10dec - 1exi + 2 67
 MTR3 2 Metrics: Query Complexity Complexity: 143 67

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_getmessage  
   reads table sybsystemprocs..sysusermessages  
   reads table master..sysmessages (1)  
   reads table master..syslanguages (1)  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  

CALLERS
called by proc sybsystemprocs..sp_spaceusage_showhelp_all  
   called by proc sybsystemprocs..sp_spaceusage_showhelp  
      called by proc sybsystemprocs..sp_spaceusage