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


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 250
 MCTR 4 Conditional Begin Tran or Commit Tran 293
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MTYP 4 Assignment type mismatch @templatedb: sysname = varchar(349) 304
 MTYP 4 Assignment type mismatch attribute: smallint = int 434
 MTYP 4 Assignment type mismatch class: smallint = int 434
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 221
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
124
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 110
 QTYP 4 Comparison type mismatch smallint = int 110
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 126
 QTYP 4 Comparison type mismatch smallint = int 126
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 216
 QTYP 4 Comparison type mismatch smallint = int 216
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 217
 QTYP 4 Comparison type mismatch smallint = int 217
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 234
 QTYP 4 Comparison type mismatch smallint = int 234
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 235
 QTYP 4 Comparison type mismatch smallint = int 235
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 245
 QTYP 4 Comparison type mismatch smallint = int 245
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 246
 QTYP 4 Comparison type mismatch smallint = int 246
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 253
 QTYP 4 Comparison type mismatch smallint = int 253
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 254
 QTYP 4 Comparison type mismatch smallint = int 254
 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 278
 QTYP 4 Comparison type mismatch smallint = int 278
 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 313
 QTYP 4 Comparison type mismatch smallint = int 313
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 314
 QTYP 4 Comparison type mismatch smallint = int 314
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 334
 QTYP 4 Comparison type mismatch smallint = int 334
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 335
 QTYP 4 Comparison type mismatch smallint = int 335
 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 341
 QTYP 4 Comparison type mismatch smallint = int 341
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 354
 QTYP 4 Comparison type mismatch smallint = int 354
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 355
 QTYP 4 Comparison type mismatch smallint = int 355
 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 377
 QTYP 4 Comparison type mismatch smallint = int 377
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 378
 QTYP 4 Comparison type mismatch smallint = int 378
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 417
 QTYP 4 Comparison type mismatch smallint = int 417
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 418
 QTYP 4 Comparison type mismatch smallint = int 418
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 453
 QTYP 4 Comparison type mismatch smallint = int 453
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 454
 QTYP 4 Comparison type mismatch smallint = int 454
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 463
 QTYP 4 Comparison type mismatch smallint = int 463
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 464
 QTYP 4 Comparison type mismatch smallint = int 464
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 481
 QTYP 4 Comparison type mismatch smallint = int 481
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 482
 QTYP 4 Comparison type mismatch smallint = int 482
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 491
 QTYP 4 Comparison type mismatch smallint = int 491
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 492
 QTYP 4 Comparison type mismatch smallint = int 492
 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 209
 MNER 3 No Error Check should check return value of exec 221
 MUCO 3 Useless Code Useless Brackets 96
 MUCO 3 Useless Code Useless Brackets 105
 MUCO 3 Useless Code Useless Brackets 115
 MUCO 3 Useless Code Useless Brackets 130
 MUCO 3 Useless Code Useless Brackets 138
 MUCO 3 Useless Code Useless Brackets 147
 MUCO 3 Useless Code Useless Brackets 153
 MUCO 3 Useless Code Useless Brackets 156
 MUCO 3 Useless Code Useless Brackets 174
 MUCO 3 Useless Code Useless Brackets 175
 MUCO 3 Useless Code Useless Brackets 183
 MUCO 3 Useless Code Useless Brackets 196
 MUCO 3 Useless Code Useless Brackets 219
 MUCO 3 Useless Code Useless Brackets 223
 MUCO 3 Useless Code Useless Brackets 242
 MUCO 3 Useless Code Useless Brackets 257
 MUCO 3 Useless Code Useless Brackets 270
 MUCO 3 Useless Code Useless Brackets 283
 MUCO 3 Useless Code Useless Brackets 308
 MUCO 3 Useless Code Useless Brackets 317
 MUCO 3 Useless Code Useless Brackets 320
 MUCO 3 Useless Code Useless Brackets 323
 MUCO 3 Useless Code Useless Brackets 326
 MUCO 3 Useless Code Useless Brackets 346
 MUCO 3 Useless Code Useless Brackets 365
 MUCO 3 Useless Code Useless Brackets 370
 MUCO 3 Useless Code Useless Brackets 382
 MUCO 3 Useless Code Useless Brackets 392
 MUCO 3 Useless Code Useless Brackets 397
 MUCO 3 Useless Code Useless Brackets 409
 MUCO 3 Useless Code Useless Brackets 411
 MUCO 3 Useless Code Useless Brackets 413
 MUCO 3 Useless Code Useless Brackets 421
 MUCO 3 Useless Code Useless Brackets 435
 MUCO 3 Useless Code Useless Brackets 473
 MUCO 3 Useless Code Useless Brackets 504
 QAFM 3 Var Assignment from potentially many rows 122
 QAFM 3 Var Assignment from potentially many rows 244
 QAFM 3 Var Assignment from potentially many rows 310
 QAFM 3 Var Assignment from potentially many rows 339
 QAFM 3 Var Assignment from potentially many rows 359
 QCRS 3 Conditional Result Set 458
 QCRS 3 Conditional Result Set 486
 QISO 3 Set isolation level 71
 QISO 3 Set isolation level 203
 QIWC 3 Insert with not all columns specified missing 9 columns out of 15 433
 QNAJ 3 Not using ANSI Inner Join 211
 QNUA 3 Should use Alias: Column def_remote_loc should use alias s 215
 QNUA 3 Should use Alias: Column class should use alias a 216
 QNUA 3 Should use Alias: Column attribute should use alias a 217
 QNUA 3 Should use Alias: Column object_type should use alias a 218
 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}
216
 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}
234
 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}
245
 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}
253
 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}
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, attribute, class}
278
 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}
312
 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}
334
 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}
340
 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}
354
 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}
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: {class, object_type, attribute}
377
 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}
417
 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}
453
 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}
463
 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}
481
 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}
491
 VNRD 3 Variable is not read @sysattr_over 60
 VNRD 3 Variable is not read @sysdb_over 61
 VNRD 3 Variable is not read @exists 364
 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 458
 MRST 2 Result Set Marker 486
 MSUB 2 Subquery Marker 109
 MSUB 2 Subquery Marker 126
 MSUB 2 Subquery Marker 233
 MSUB 2 Subquery Marker 270
 MSUB 2 Subquery Marker 333
 MSUB 2 Subquery Marker 353
 MSUB 2 Subquery Marker 452
 MSUB 2 Subquery Marker 480
 MTR1 2 Metrics: Comments Ratio Comments: 38% 31
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 65 = 79dec - 16exi + 2 31
 MTR3 2 Metrics: Query Complexity Complexity: 277 31
 PRED_QUERY_COLLECTION 2 {a=master..sysattributes, d=master..sysdatabases} 0 209

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_autoformat  
   reads table tempdb..syscolumns (1)  
   read_writes table tempdb..#colinfo_af (1) 
   calls proc sybsystemprocs..sp_autoformat  
   reads table master..syscolumns (1)  
   reads table tempdb..systypes (1)  
   reads table master..systypes (1)  
   calls proc sybsystemprocs..sp_namecrack  
reads table master..spt_values (1)  
writes table tempdb..#template (1) 
read_writes table master..sysattributes (1)  
reads table master..sysdatabases (1)