DatabaseProcApplicationCreatedLinks
sybsystemprocssp_dbrecovery_order  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/%M% %I% %G% */
3     
4     /*
5     ** 17260, "Can't run %1! from within a transaction." 
6     ** 17421, "No such database -- run sp_helpdb to list databases."
7     ** 17422, "The 'master' database's options can not be changed."
8     ** 17428, "You must be in the 'master' database in order to change
9     **	database options."                                
10    ** 18600, "%1!: Illegal option. The only legal option is 'force'."
11    ** 18601, "%1!: The database %2! has no user specified recovery order."
12    ** 18602, "%1!: The database %2! already has the user specified recovery order of %3!."
13    ** 18603, "%1!: The recovery order %2! is already in use for database %3!"
14    ** 18604, "%1!: Invalid recovery order. The next valid recovery order is: %2!"
15    ** 18605, "%1!: The database '%2!' has no user specified recovery order.
16    ** 18607, "%1!: No databases have user specified recovery order. All databases will 
17    **             be recovered in database id order."
18    ** 18608, "%1!: Delete row from master.dbo.sysattributes failed. Command aborted."
19    ** 18609, "%1!: Update row of master.dbo.sysattributes failed. Command aborted."
20    ** 18610, "%1!: Insert row to master.dbo.sysattributes failed. Command aborted."
21    ** 19110, "%1: Illegal mode for recovery order. The only legal modes are 
22    **	  'strict' or 'relax'."
23    ** 19995, "You must define the recovery order of the database '%1!' before 
24    **	   defining the recovery order of any database that uses it as a template 
25    **	   database."
26    ** 19996, "The recovery order of database '%1!' cannot precede the recovery order 
27    **	'%2!' of its template database '%3!'."
28    ** 19997, "You must delete the recovery order of any database that uses this 
29    **	  database as template before changing the template database recovery order."
30    */
31    create or replace procedure sp_dbrecovery_order
32        @dbname varchar(30) = NULL,
33        @rec_order int = - 123456,
34        @option char(6) = NULL,
35        @mode char(10) = NULL
36    as
37        declare @dbid int, /* dbid of the database */
38            @dbid1 int, /* dbid of the database */
39            @dbid2 int, /* dbid of the database */
40            @attrib_id int,
41            @dbname1 sysname,
42            @name sysname,
43            @object_type varchar(2),
44            @msg varchar(250),
45            @sysattr_over int,
46            @sysdb_over int,
47            @order int,
48            @class int,
49            @sysdbid int,
50            @high_rec_order int,
51            @exists int,
52            @procname varchar(20),
53            @error_status int,
54            @templatedb sysname,
55            @template_order int
56    
57        declare @nullarg char(1)
58        declare @dummy int
59        declare @status int
60        declare @gp_enabled int
61    
62    
63        select @attrib_id = 6 /* attribute is  RECOVERY ORDER */
64        select @object_type = 'D'
65        select @class = 10
66        select @sysattr_over = 0
67        select @sysdb_over = 0
68        select @exists = 0
69        select @procname = "sp_dbrecovery_order"
70        select @error_status = 0
71    
72    
73        if @@trancount = 0
74        begin --{
75            set chained off
76        end --}
77    
78        set transaction isolation level 1
79    
80        /* First, Check all the parameters */
81    
82        /*
83        **  If no @dbname given, display the recovery order of all databases
84        */
85    
86        if @dbname is null
87            goto display_settings_all
88    
89        /*
90        **  Verify the database name and get the @dbid 
91        */
92        select @dbid = db_id(@dbname)
93    
94        /*
95        **  If @dbname not found, say so.
96        */
97        if @dbid is NULL
98        begin --{
99            /*
100           ** 17421, "No such database -- run sp_helpdb to list databases."
101           */
102           raiserror 17421
103           return (1)
104       end --}
105   
106       if @dbname in ("master", "model", "tempdb", "sybsecurity", "sybsystemprocs", "sybsystemdb")
107       begin --{
108           /*
109           ** , "'%1!':Not allowed for System databases."
110           */
111           raiserror 18523, @procname
112           return (1)
113       end --}
114   
115       /* The database recovery order cannot be set for an archive database. */
116       if exists (select * from master.dbo.sysdatabases
117               where dbid = @dbid
118                   and (status3 & 4194304) = 4194304)
119       begin --{
120           /* Cannot run '%1!' on an archive database." */
121           raiserror 19424, @procname
122           return (1)
123       end --}
124   
125       /* In SDC, specify rec order for local system tempdb is not allowed either */
126       if @@clustermode = "shared disk cluster"
127       begin --{
128           declare @localsystempdbbit int
129           select @localsystempdbbit = number
130           from master.dbo.spt_values
131           where type = "D3" and name = "local system temp db"
132   
133           if exists (select 1 from master.dbo.sysdatabases where dbid = @dbid and
134                       (status3 & @localsystempdbbit) = @localsystempdbbit)
135           begin --{
136               raiserror 18523, @procname
137               return (1)
138           end --}
139       end --}
140   
141   
142       /*
143       ** If only dbname is provided, then display the settings for the database
144       */
145       if (@rec_order = - 123456)
146           goto display_settings
147   
148       if @option is not null
149       begin --{
150           if @option != "force"
151           begin --{
152               /* 18600, "%1!: Illegal option. The only legal option is 'force'." */
153               raiserror 18600, @procname
154               return (1)
155           end --}
156       end --}
157   
158       if @mode is not null
159       begin --{
160           if (@mode not in ("strict", "relax"))
161           begin --{
162               raiserror 19110, @procname
163               return (1)
164           end --}
165       end --}
166       else
167       begin --{
168           /* Default mode is relax */
169           select @mode = "relax"
170       end --}
171   
172       /*
173       ** the following logic till the label "display_settings" is for setting the
174       ** the recovery order
175       */
176   
177       /*
178       **  If granular permissions is not enabled:
179       **  Only the Accounts with SA role can execute it.
180       **  Call proc_role() with the required SA role.
181       **  If granular permissions is enabled then the
182       **  permission 'manage server' is required.
183       */
184   
185       select @nullarg = NULL
186       execute @status = sp_aux_checkroleperm "sa_role",
187           "manage server", @nullarg, @gp_enabled output
188   
189       /* For Auditing */
190       if (@gp_enabled = 0)
191       begin
192           if (proc_role("sa_role") = 0)
193               return (1)
194       end
195       else
196       begin
197           select @dummy = proc_auditperm("manage server", @status)
198       end
199   
200       if (@status != 0)
201           return (1)
202   
203       if db_name() != "master"
204       begin --{
205           /*
206           ** 17428, "You must be in the 'master' database in order to change database options." 
207           */
208           raiserror 17428
209           return (1)
210       end --}
211   
212       /*
213       **  If we're in a transaction, disallow this since it might make recovery
214       **  impossible.
215       */
216       if @@trancount > 0
217       begin --{
218           /*
219           ** 17260, "Can't run %1! from within a transaction." 
220           */
221           raiserror 17260, @procname
222           return (1)
223       end --}
224       else
225       begin --{
226           set chained off
227       end --}
228   
229       set transaction isolation level 1
230   
231       /*
232       ** If this database is being used as a template, its recovery order
233       ** cannot be changed.
234       */
235       select s.name, s.def_remote_loc as templatedb
236       into #template
237       from master.dbo.sysattributes a,
238           master.dbo.sysdatabases s
239       where db_id(s.name) = a.object and
240           s.name != @dbname and
241           def_remote_loc = @dbname and
242           class = @class and
243           attribute = @attrib_id and
244           object_type = @object_type
245       if (@@rowcount > 0)
246       begin --{
247           exec sp_autoformat #template
248           raiserror 19997
249           return (1)
250       end --}
251   
252       /*
253       ** if the command is for deleting the recovery order, then delete the row and
254       ** update the rest 
255       */
256       if @rec_order = - 1
257       begin --{
258           /* first note the current recovery order if it exists */
259           if not exists (select * from master.dbo.sysattributes
260                   where class = @class AND
261                       attribute = @attrib_id AND
262                       object_type = @object_type AND
263                       object = @dbid)
264           begin --{
265               /* print error and exit */
266               /* 18601, "%1!: The database %2! has no user specified recovery order." */
267               raiserror 18601, @procname, @dbname
268               return (1)
269           end --}
270           select @rec_order = int_value from master.dbo.sysattributes
271           where class = @class AND
272               attribute = @attrib_id AND
273               object_type = @object_type AND
274               object = @dbid
275           /* now delete the row and update the rest within a transaction.*/
276           begin transaction delete_update
277   
278           delete master.dbo.sysattributes
279           where class = @class AND
280               attribute = @attrib_id AND
281               object_type = @object_type AND
282               object = @dbid
283           if (@@error != 0)
284           begin --{
285               /* 18608, "%1!: Delete row from master.dbo.sysattributes failed. Command aborted." */
286               raiserror 18608, @procname
287               rollback tran delete_update
288               select @error_status = 1
289               goto display_settings_all
290           end --}
291           /* 
292           ** now fixup the recovery order of the databases with higher recovery order
293           ** by decrementing by one
294           */
295           select @rec_order = @rec_order + 1
296           while (exists (select * from master.dbo.sysattributes
297                       where class = @class AND
298                           attribute = @attrib_id AND
299                           object_type = @object_type AND
300                           int_value = @rec_order))
301           begin --{
302               update master.dbo.sysattributes
303               set int_value = @rec_order - 1
304               where class = @class AND
305                   attribute = @attrib_id AND
306                   object_type = @object_type AND
307                   int_value = @rec_order
308   
309               if (@@error != 0)
310               begin --{
311                   /* 18609, "%1!: Update row of master.dbo.sysattributes failed. Command aborted."*/
312                   raiserror 18609, @procname
313                   rollback tran delete_update
314                   select @error_status = 1
315                   goto display_settings_all
316               end --}
317               select @rec_order = @rec_order + 1
318           end --}
319           commit transaction delete_update
320           goto display_settings_all
321       end --}
322   
323       /*
324       ** We must define the recovery order of a template before defining
325       ** the recovery order of any database that uses it as a template
326       ** database. This must be done after testing it's not -1, that
327       ** would be smaller than anyone else, but it's used to delete
328       ** the entry.
329       */
330       select @templatedb = def_remote_loc
331       from master.dbo.sysdatabases
332       where name = @dbname
333   
334       if (@templatedb is not null)
335       begin -- {
336           select @template_order = int_value
337           from master.dbo.sysattributes
338           where object = db_id(@templatedb) and
339               class = @class and
340               attribute = @attrib_id and
341               object_type = @object_type
342   
343           if (@template_order is NULL)
344           begin --{
345               raiserror 19995, @templatedb
346               return (1)
347           end --}
348   
349           if (@rec_order <= @template_order)
350           begin --{
351               raiserror 19996, @dbname, @template_order, @templatedb
352               return (1)
353           end --}
354       end --}
355   
356       /*
357       ** if an entry already exists for this database print error, display the order and exit
358       */
359       if exists (select * from master.dbo.sysattributes where
360                   class = @class AND
361                   attribute = @attrib_id AND
362                   object_type = @object_type AND
363                   object = @dbid)
364       begin --{
365           select @order = int_value from master.dbo.sysattributes where
366               class = @class AND
367               attribute = @attrib_id AND
368               object_type = @object_type AND
369               object = @dbid
370           /* 18602, "%1!: The database %2! already has the user specified recovery order of %3!." */
371           raiserror 18602, @procname, @dbname, @order
372           return (1)
373       end --}
374   
375       /*
376       ** If there is another database at this order, then display error and exit
377       */
378   
379       if exists (select * from master.dbo.sysattributes where
380                   class = @class AND
381                   attribute = @attrib_id AND
382                   object_type = @object_type AND
383                   int_value = @rec_order)
384       begin --{
385           select @dbid1 = object from master.dbo.sysattributes where
386               class = @class AND
387               attribute = @attrib_id AND
388               object_type = @object_type AND
389               int_value = @rec_order
390           select @exists = 1
391           if (@dbid != @dbid1 AND @option is null)
392           begin --{
393               select @dbname1 = db_name(@dbid1)
394               /* 18603, "%1!: The recovery order %2! is already in use for database %3!." */
395               raiserror 18603, @procname, @rec_order, @dbname1
396               return (1)
397           end --}
398       end --}
399   
400   
401       /* find the highest existing user defined recovery order */
402       select @high_rec_order = max(int_value) from master.dbo.sysattributes where
403           class = @class AND
404           attribute = @attrib_id AND
405           object_type = @object_type
406   
407       /* if no recovery order exists, initialize high_recovery_order */
408       if (@high_rec_order is NULL)
409           select @high_rec_order = 0
410   
411       /* the next valid recovery order is one greater than the current high */
412       select @high_rec_order = @high_rec_order + 1
413   
414       /* Check for validity of the requested recovery order. 
415       ** It should be between 1 and high_rec_order OR 
416       ** if less than high_rec_order then it must have "force" option.
417       */
418       if ((@rec_order < 1) OR (@rec_order > @high_rec_order) OR
419               ((@rec_order < @high_rec_order) AND @option != "force"))
420       begin --{
421           /* 18604, "%1!: Invalid recovery order. The next valid recovery order is: %2!" */
422           raiserror 18604, @procname, @high_rec_order
423           return (1)
424       end --}
425   
426       /* 
427       ** now the specified recovery order is equal to high_rec_order or
428       ** between 1 and current maximum user specified recovery order with "force" option.
429       */
430   
431       /* if  between 1 and high_rec_order then increment all the recovery orders greater 
432       ** than the rec_order and then insert the new row */
433       begin transaction update_insert
434   
435       if (@rec_order < @high_rec_order)
436       begin --{
437           while (1 = 1)
438           begin --{
439               if (@high_rec_order <= @rec_order)
440                   break
441               update master.dbo.sysattributes
442               set int_value = @high_rec_order
443               where class = @class AND
444                   attribute = @attrib_id AND
445                   object_type = @object_type AND
446                   int_value = @high_rec_order - 1
447               if (@@error != 0)
448               begin --{
449                   /* 18609, "%1!: Update row of master.dbo.sysattributes failed. Command aborted." */
450                   raiserror 18609, @procname
451                   rollback transaction update_insert
452                   select @error_status = 1
453                   goto display_settings_all
454               end --}
455               select @high_rec_order = @high_rec_order - 1
456           end --}
457       end --}
458       insert master.dbo.sysattributes
459       (class, attribute, object_type, object, int_value, comments)
460       values (@class, @attrib_id, @object_type, @dbid, @rec_order, @mode)
461       if (@@error != 0)
462       begin --{
463           /* 18610, "%1!: Insert row to master.dbo.sysattributes failed. Command aborted." */
464           raiserror 18610, @procname
465           rollback transaction update_insert
466           select @error_status = 1
467           goto display_settings_all
468       end --}
469   
470       commit transaction update_insert
471       goto display_settings_all
472   
473   
474       /*
475       ** Display the setting - only one db 
476       */
477   display_settings:
478       if exists (select * from master.dbo.sysattributes
479               where class = @class AND
480                   attribute = @attrib_id AND
481                   object_type = @object_type AND
482                   object = @dbid)
483       begin --{
484           select "Database Name" = convert(varchar(13), @dbname),
485               "Database id" = "    " + convert(varchar(6), @dbid),
486               "Recovery Order" = "   " + convert(varchar(6), int_value),
487               "Mode" = "   " + convert(varchar(6), comments)
488           from master.dbo.sysattributes
489           where class = @class AND
490               attribute = @attrib_id AND
491               object_type = @object_type AND
492               object = @dbid
493       end --}
494       else
495       begin --{
496           /* 18601, "%1!: The database '%2!' does not have user specified recovery order." */
497           raiserror 18601, @procname, @dbname
498       end --}
499       return (@error_status)
500   
501   
502       /*
503       ** Display the setting - ALL 
504       */
505   display_settings_all:
506       if exists (select * from master.dbo.sysattributes
507               where class = @class AND
508                   attribute = @attrib_id AND
509                   object_type = @object_type)
510       begin --{
511           print "The following databases have user specified recovery order:"
512           select "Database Name" = convert(varchar(30), db_name(object)),
513               "Database Id" = "    " + convert(varchar(6), object),
514               "Recovery Order" = "    " + convert(varchar(6), int_value),
515               "Mode" = "   " + convert(varchar(6), comments)
516           from master.dbo.sysattributes
517           where class = @class AND
518               attribute = @attrib_id AND
519               object_type = @object_type
520           order by int_value
521           print "The rest of the databases will be recovered in default database id order."
522       end --}
523       else
524       begin --{
525           /* 18607, "%1!: No databases have user specified recovery order. All data
526           **		bases will be recovered in database id order."
527           */
528           raiserror 18607, @procname
529       end --}
530       return (@error_status)
531   


exec sp_procxmode 'sp_dbrecovery_order', 'AnyMode'
go

Grant Execute on sp_dbrecovery_order to public
go
RESULT SETS
sp_dbrecovery_order_rset_002
sp_dbrecovery_order_rset_001

DEFECTS
 MCTR 4 Conditional Begin Tran or Commit Tran 276
 MCTR 4 Conditional Begin Tran or Commit Tran 319
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MTYP 4 Assignment type mismatch @templatedb: sysname = varchar(349) 330
 MTYP 4 Assignment type mismatch attribute: smallint = int 460
 MTYP 4 Assignment type mismatch class: smallint = int 460
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 247
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
131
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 117
 QTYP 4 Comparison type mismatch smallint = int 117
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 133
 QTYP 4 Comparison type mismatch smallint = int 133
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 242
 QTYP 4 Comparison type mismatch smallint = int 242
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 243
 QTYP 4 Comparison type mismatch smallint = int 243
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 260
 QTYP 4 Comparison type mismatch smallint = int 260
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 261
 QTYP 4 Comparison type mismatch smallint = int 261
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 271
 QTYP 4 Comparison type mismatch smallint = int 271
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 272
 QTYP 4 Comparison type mismatch smallint = int 272
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 279
 QTYP 4 Comparison type mismatch smallint = int 279
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 280
 QTYP 4 Comparison type mismatch smallint = int 280
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 297
 QTYP 4 Comparison type mismatch smallint = int 297
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 298
 QTYP 4 Comparison type mismatch smallint = int 298
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 304
 QTYP 4 Comparison type mismatch smallint = int 304
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 305
 QTYP 4 Comparison type mismatch smallint = int 305
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 339
 QTYP 4 Comparison type mismatch smallint = int 339
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 340
 QTYP 4 Comparison type mismatch smallint = int 340
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 360
 QTYP 4 Comparison type mismatch smallint = int 360
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 361
 QTYP 4 Comparison type mismatch smallint = int 361
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 366
 QTYP 4 Comparison type mismatch smallint = int 366
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 367
 QTYP 4 Comparison type mismatch smallint = int 367
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 380
 QTYP 4 Comparison type mismatch smallint = int 380
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 381
 QTYP 4 Comparison type mismatch smallint = int 381
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 386
 QTYP 4 Comparison type mismatch smallint = int 386
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 387
 QTYP 4 Comparison type mismatch smallint = int 387
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 403
 QTYP 4 Comparison type mismatch smallint = int 403
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 404
 QTYP 4 Comparison type mismatch smallint = int 404
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 443
 QTYP 4 Comparison type mismatch smallint = int 443
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 444
 QTYP 4 Comparison type mismatch smallint = int 444
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 479
 QTYP 4 Comparison type mismatch smallint = int 479
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 480
 QTYP 4 Comparison type mismatch smallint = int 480
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 489
 QTYP 4 Comparison type mismatch smallint = int 489
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 490
 QTYP 4 Comparison type mismatch smallint = int 490
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 507
 QTYP 4 Comparison type mismatch smallint = int 507
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 508
 QTYP 4 Comparison type mismatch smallint = int 508
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 517
 QTYP 4 Comparison type mismatch smallint = int 517
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 518
 QTYP 4 Comparison type mismatch smallint = int 518
 TNOU 4 Table with no unique index master..spt_values master..spt_values
 MGTP 3 Grant to public master..spt_values  
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public master..sysdatabases  
 MGTP 3 Grant to public sybsystemprocs..sp_dbrecovery_order  
 MNER 3 No Error Check should check @@error after select into 235
 MNER 3 No Error Check should check return value of exec 247
 MUCO 3 Useless Code Useless Brackets 103
 MUCO 3 Useless Code Useless Brackets 112
 MUCO 3 Useless Code Useless Brackets 122
 MUCO 3 Useless Code Useless Brackets 137
 MUCO 3 Useless Code Useless Brackets 145
 MUCO 3 Useless Code Useless Brackets 154
 MUCO 3 Useless Code Useless Brackets 160
 MUCO 3 Useless Code Useless Brackets 163
 MUCO 3 Useless Code Useless Brackets 190
 MUCO 3 Useless Code Useless Brackets 192
 MUCO 3 Useless Code Useless Brackets 193
 MUCO 3 Useless Code Useless Brackets 200
 MUCO 3 Useless Code Useless Brackets 201
 MUCO 3 Useless Code Useless Brackets 209
 MUCO 3 Useless Code Useless Brackets 222
 MUCO 3 Useless Code Useless Brackets 245
 MUCO 3 Useless Code Useless Brackets 249
 MUCO 3 Useless Code Useless Brackets 268
 MUCO 3 Useless Code Useless Brackets 283
 MUCO 3 Useless Code Useless Brackets 296
 MUCO 3 Useless Code Useless Brackets 309
 MUCO 3 Useless Code Useless Brackets 334
 MUCO 3 Useless Code Useless Brackets 343
 MUCO 3 Useless Code Useless Brackets 346
 MUCO 3 Useless Code Useless Brackets 349
 MUCO 3 Useless Code Useless Brackets 352
 MUCO 3 Useless Code Useless Brackets 372
 MUCO 3 Useless Code Useless Brackets 391
 MUCO 3 Useless Code Useless Brackets 396
 MUCO 3 Useless Code Useless Brackets 408
 MUCO 3 Useless Code Useless Brackets 418
 MUCO 3 Useless Code Useless Brackets 423
 MUCO 3 Useless Code Useless Brackets 435
 MUCO 3 Useless Code Useless Brackets 437
 MUCO 3 Useless Code Useless Brackets 439
 MUCO 3 Useless Code Useless Brackets 447
 MUCO 3 Useless Code Useless Brackets 461
 MUCO 3 Useless Code Useless Brackets 499
 MUCO 3 Useless Code Useless Brackets 530
 QAFM 3 Var Assignment from potentially many rows 129
 QAFM 3 Var Assignment from potentially many rows 270
 QAFM 3 Var Assignment from potentially many rows 336
 QAFM 3 Var Assignment from potentially many rows 365
 QAFM 3 Var Assignment from potentially many rows 385
 QCRS 3 Conditional Result Set 484
 QCRS 3 Conditional Result Set 512
 QISO 3 Set isolation level 78
 QISO 3 Set isolation level 229
 QIWC 3 Insert with not all columns specified missing 9 columns out of 15 459
 QNAJ 3 Not using ANSI Inner Join 237
 QNUA 3 Should use Alias: Column def_remote_loc should use alias s 241
 QNUA 3 Should use Alias: Column class should use alias a 242
 QNUA 3 Should use Alias: Column attribute should use alias a 243
 QNUA 3 Should use Alias: Column object_type should use alias a 244
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class, object_type, attribute}
242
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
260
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
271
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
279
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, attribute, class}
297
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, attribute, class}
304
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
338
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
360
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
366
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, attribute, class}
380
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, attribute, class}
386
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class, object_type, attribute}
403
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, attribute, class}
443
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
479
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object, attribute, class}
489
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class, object_type, attribute}
507
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class, object_type, attribute}
517
 VNRD 3 Variable is not read @sysattr_over 66
 VNRD 3 Variable is not read @sysdb_over 67
 VNRD 3 Variable is not read @dummy 197
 VNRD 3 Variable is not read @exists 390
 VUNU 3 Variable is not used @dbid2 39
 VUNU 3 Variable is not used @name 42
 VUNU 3 Variable is not used @msg 44
 VUNU 3 Variable is not used @sysdbid 49
 MRST 2 Result Set Marker 484
 MRST 2 Result Set Marker 512
 MSUB 2 Subquery Marker 116
 MSUB 2 Subquery Marker 133
 MSUB 2 Subquery Marker 259
 MSUB 2 Subquery Marker 296
 MSUB 2 Subquery Marker 359
 MSUB 2 Subquery Marker 379
 MSUB 2 Subquery Marker 478
 MSUB 2 Subquery Marker 506
 MTR1 2 Metrics: Comments Ratio Comments: 37% 31
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 67 = 82dec - 17exi + 2 31
 MTR3 2 Metrics: Query Complexity Complexity: 289 31
 PRED_QUERY_COLLECTION 2 {a=master..sysattributes, d=master..sysdatabases} 0 235

DATA PROPAGATION detailed
ColumnWritten To
@dbnamesysattributes.object   °.object_info1   °.object_info3   °.char_value   sysremotelogins.remoteserverid   sysservers.srvid   sysattributes.object_info1   °.object_info3   °.int_value   °.char_value  
sp_dropdevice_rset_001.device sp_checknames_rset_006.remoteserverid sp_checknames_rset_007.srvid sp_checknames_rset_008.srvid sp_dbrecovery_order_rset_001.Database Name °.Database id sp_dbrecovery_order_rset_002.Database Name °.Database Id sp_displayroles_rset_001.Role Name sp_displayroles_rset_002.Role Name
°.Grantee sp_displayroles_rset_003.Role Name sp_displayroles_rset_004.Role Name sp_dropdevice_rset_001.device sp_forceonline_object_rset_001.Object °.status sp_forceonline_object_rset_002.Object °.status sp_forceonline_page_rset_001.status sp_forceonline_page_rset_002.status
sp_listsuspect_object_rset_001.Object °.Access sp_listsuspect_page_rset_001.Object °.Access sp_makesuspect_obj_rset_001.Obj °.Indid °.LogType °.PageType °.ErrType °.Delay
°.TotalNum sp_makesuspect_obj_rset_002.Obj °.Indid °.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_makesuspect_obj_rset_003.Obj °.Indid
°.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_memlog_rset_001.dumps_per_file sp_passwordpolicy_rset_001.message sp_passwordpolicy_rset_002.value sp_passwordpolicy_rset_003.value sp_passwordpolicy_rset_004.Policy_option
sp_rjs_retrieve_rset_001.host_name sp_setsuspect_granularity_rset_001.Online mode sp_ssladmin_rset_001.certificate_path sp_ssladmin_rset_002.Cipher Suite Name °.Preference
@modesysattributes.comments   sp_dbrecovery_order_rset_001.Mode sp_dbrecovery_order_rset_002.Mode sp_ssladmin_rset_003.Cipher Suite Name
@rec_ordersysattributes.object   °.object_info1   °.object_info3   °.int_value   °.char_value   sysremotelogins.remoteserverid   sysservers.srvid   sysattributes.object_info1   °.object_info3   °.int_value  
°.char_value   sp_dropdevice_rset_001.device sp_checknames_rset_006.remoteserverid sp_checknames_rset_007.srvid sp_checknames_rset_008.srvid sp_dbrecovery_order_rset_001.Database Name °.Database id °.Recovery Order sp_dbrecovery_order_rset_002.Recovery Order sp_displayroles_rset_001.Role Name
sp_displayroles_rset_002.Role Name °.Grantee sp_displayroles_rset_003.Role Name sp_displayroles_rset_004.Role Name sp_dropdevice_rset_001.device sp_forceonline_object_rset_001.Objid °.Object °.status sp_forceonline_object_rset_002.Objid °.Object
°.status sp_forceonline_page_rset_001.Pageid °.status sp_forceonline_page_rset_002.Pageid °.status sp_listsuspect_object_rset_001.Objid °.Object °.Access sp_listsuspect_page_rset_001.Pageid °.Object
°.Access sp_makesuspect_obj_rset_001.Obj °.Indid °.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_makesuspect_obj_rset_002.Obj °.Indid
°.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_makesuspect_obj_rset_003.Obj °.Indid °.LogType °.PageType °.ErrType
°.Delay °.TotalNum sp_memlog_rset_001.dumps_per_file sp_passwordpolicy_rset_001.message sp_passwordpolicy_rset_002.value sp_passwordpolicy_rset_003.value sp_passwordpolicy_rset_004.Policy_option sp_rjs_retrieve_rset_001.host_name °.host_port sp_setsuspect_error_rset_001.Error Num
sp_setsuspect_error_rset_002.Error Num sp_setsuspect_granularity_rset_001.Online mode sp_setsuspect_threshold_rset_001.Cur. Suspect threshold sp_setsuspect_threshold_rset_002.Cur. Suspect Threshold sp_ssladmin_rset_001.certificate_path sp_ssladmin_rset_002.Cipher Suite Name °.Preference

DEPENDENCIES
PROCS AND TABLES USED
read_writes table master..sysattributes (1)  
writes table sybsystemprocs..sp_dbrecovery_order_rset_002 
writes table tempdb..#template (1) 
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)  
calls proc sybsystemprocs..sp_autoformat  
   reads table tempdb..syscolumns (1)  
   writes table sybsystemprocs..sp_autoformat_rset_003 
   calls proc sybsystemprocs..sp_autoformat  
   writes table sybsystemprocs..sp_autoformat_rset_002 
   calls proc sybsystemprocs..sp_namecrack  
   reads table tempdb..systypes (1)  
   writes table sybsystemprocs..sp_autoformat_rset_005 
   reads table master..syscolumns (1)  
   reads table master..systypes (1)  
   read_writes table tempdb..#colinfo_af (1) 
   writes table sybsystemprocs..sp_autoformat_rset_001 
   writes table sybsystemprocs..sp_autoformat_rset_004 
reads table master..spt_values (1)  
reads table master..sysdatabases (1)  
writes table sybsystemprocs..sp_dbrecovery_order_rset_001