DatabaseProcApplicationCreatedLinks
sybsystemprocssp_unbindrule  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
3     /*	4.8	1.1	06/14/90	sproc/src/serveroption */
4     
5     /*
6     ** Messages for "sp_unbindrule"         17850
7     **
8     ** 17756, "The execution of the stored procedure '%1!' in database
9     **         '%2!' was aborted because there was an error in writing the
10    **         replication log record."
11    ** 17763, "The execution of the stored procedure '%1!' in database '%2!' was aborted because there
12    **         was an error in updating the schemacnt column in sysobjects."
13    ** 17840, "Column or usertype must be in 'current' database."
14    ** 17843, "You do not own a table with a column of that name."
15    ** 17844, "You do not own a user datatype of that name." 
16    ** 17850, "Rule unbound from table column."
17    ** 17851, "The specified column has no rule."
18    ** 17852, "The specified user datatype has no rule."
19    ** 17853, "Rule unbound from datatype."
20    ** 17854, "Columns of the user datatype specified had their rules unbound."
21    ** 17855, "You cannot unbind a declared constraint. Use ALTER TABLE command."
22    ** 18293, "Auditing for '%1!' event has failed due to internal error. Contact a user with System Security Officer (SSO) role."
23    */
24    
25    create or replace procedure sp_unbindrule
26        @objname varchar(511), /* table/column or datatype name */
27        @futureonly varchar(15) = NULL, /* flag to indicate extent of binding */
28        @whichrule varchar(15) = NULL
29    as
30    
31        declare @tot_constr int /* total number of constraints */
32        declare @colid smallint /* column id */
33        declare @futurevalue varchar(15) /* the value of @futureonly that causes
34        ** the binding to be limited */
35        declare @msg varchar(1024)
36        declare @returncode int /* return from ad_hoc_audit builtin */
37        declare @eventnum int /* event number for bind default auditing */
38        declare @mod_ok int /* successful bind default auditing  */
39        declare @mod_fail int /* failure bind default auditing  */
40        declare @dbname varchar(255)
41        declare @tmp int
42        declare @rows_selected int
43        declare @access_rule int /* 0        - not an access rule.
44        ** 16777216 - is an access rule. This is
45        ** the bit in sysobjects.sysstat2 
46        ** that marks an
47        ** access_rule.
48        */
49        select @eventnum = 68 /* eventnumber for unbind rule */
50        select @mod_ok = 1
51        select @mod_fail = 2
52        select @access_rule = 16777216
53    
54        if @@trancount = 0
55        begin
56            set chained off
57        end
58    
59        set transaction isolation level 1
60    
61        set transaction isolation level 1
62    
63        select @futurevalue = "futureonly" /* initialize @futurevalue */
64    
65        /*
66        **  When a default or rule is bound to a user-defined datatype, it is also
67        **  bound, by default, to any columns of the user datatype that are currently
68        **  using the existing default or rule as their default or rule.  This default
69        **  action may be overridden by setting @futureonly = @futurevalue when the
70        **  procedure is invoked.  In this case existing columns with the user
71        **  datatype won't have their existing default or rule changed.
72        */
73    
74        /*
75        **  Check to see that the object names are local to the current database.
76        */
77        if @objname like "%.%.%"
78        begin
79            /*
80            ** 17840, "Column or usertype must be in 'current' database."
81            */
82            raiserror 17840
83            return (1)
84        end
85    
86        /*
87        **  Check that the @futureonly argument, if supplied, is correct.
88        */
89        if (@futureonly is not null)
90        begin
91            if (@futureonly != @futurevalue)
92            begin
93                /*
94                ** 17856, "Usage: sp_unbindrule objectname [,NULL| 'futureonly']
95                **			[,"all"| "accessrule"]"
96                */
97                raiserror 17856
98                return (1)
99            end
100       end
101   
102       /*
103       **	Check that the @whichrule argument, if supplied, is correct.
104       */
105       if (@whichrule is not null)
106       begin
107           if ((@whichrule != "all") and (@whichrule != "accessrule"))
108           begin
109               /*
110               ** 17856, "Usage: sp_unbindrule objectname [,NULL| 'futureonly']
111               **			[,"all"| "accessrule"]"
112               */
113               raiserror 17856
114               return (1)
115           end
116       end
117   
118   
119       /*
120       **  If @objname is of the form tab.col then we are unbinding a column.
121       **  Otherwise its a datatype.  In the column case, we need to extract
122       **  and verify the table and column names and make sure the user owns
123       **  the table that is getting the default unbound.
124       */
125       if @objname like "%.%"
126       begin
127           declare @tabname varchar(255) /* name of table */
128           declare @colname varchar(255) /* name of column */
129   
130           /*
131           **  Get the table name out.
132           */
133           select @tabname = substring(@objname, 1, charindex(".", @objname) - 1)
134           select @colname = substring(@objname, charindex(".", @objname) + 1, 511)
135   
136           /*
137           **  Find it.
138           */
139           if not exists (select syscolumns.colid
140                   from syscolumns, sysobjects
141                   where syscolumns.id = object_id(@tabname)
142                       and syscolumns.name = @colname
143                       and sysobjects.id = object_id(@tabname)
144                       and uid = user_id()
145                       and sysobjects.sysstat & 7 = 3) /* user table */
146   
147           begin
148               /*
149               ** 17843, "You do not own a table with a column of that name."
150               */
151               /* Audit the failure to unbind a rule */
152               select @returncode =
153                   ad_hoc_audit(@eventnum, @mod_fail, NULL, db_name(),
154                       @tabname, user_name(), 0, object_id(@tabname)
155                   )
156               raiserror 17843
157               return (1)
158           end
159           /* Audit the successful permission to unbind a rule */
160           select @returncode =
161               ad_hoc_audit(@eventnum, @mod_ok, NULL, db_name(),
162                   @tabname, user_name(), 0, object_id(@tabname)
163               )
164   
165           if (@returncode != 0)
166           begin
167               /* 
168               ** 18293, "Auditing for '%1!' event has failed due to 
169               ** internal error. Contact a user with System Security 
170               ** Officer (SSO) role."
171               */
172               raiserror 18293, @eventnum
173               return (1)
174           end
175           /*
176           **  Is there something bound to it?
177           */
178           if (@whichrule is NULL and
179                   exists (select syscolumns.colid
180                       from syscolumns, sysobjects
181                       where syscolumns.id = object_id(@tabname)
182                           and syscolumns.name = @colname
183                           and sysobjects.id = object_id(@tabname)
184                           and uid = user_id()
185                           and sysobjects.sysstat & 7 = 3 /* user table */
186                           and syscolumns.domain = 0))
187           begin
188               /*
189               ** 17851, "The specified column has no rule."
190               */
191               raiserror 17851
192               return (1)
193           end
194           if (@whichrule = "accessrule" and
195                   exists (select syscolumns.colid
196                       from syscolumns, sysobjects
197                       where syscolumns.id = object_id(@tabname)
198                           and syscolumns.name = @colname
199                           and sysobjects.id = object_id(@tabname)
200                           and uid = user_id()
201                           and sysobjects.sysstat & 7 = 3 /* user table */
202                           and
203                           (syscolumns.accessrule = 0
204                               or
205                               syscolumns.accessrule is NULL)))
206           begin
207               /*
208               ** FGAC_RESOLVE: qualify the msg with what rule 
209               ** 17851, "The specified column has no rule."
210               */
211               raiserror 17851
212               return (1)
213           end
214           if (@whichrule = "all" and
215                   exists (select syscolumns.colid
216                       from syscolumns, sysobjects
217                       where syscolumns.id = object_id(@tabname)
218                           and syscolumns.name = @colname
219                           and sysobjects.id = object_id(@tabname)
220                           and uid = user_id()
221                           and sysobjects.sysstat & 7 = 3 /* user table */
222                           and
223                           (syscolumns.domain = 0
224                               and
225                               isnull(syscolumns.accessrule, 0) = 0
226                           )
227                       ))
228           begin
229               /*
230               ** FGAC_RESOLVE: qualify the msg with what rule 
231               ** 17851, "The specified column has no rule."
232               */
233               raiserror 17851
234               return (1)
235           end
236   
237   
238           /*
239           ** Check to see that the rule is not of declared type
240           */
241   
242           if ((@whichrule is NULL) and
243                   exists (select * from sysprocedures
244                       where id = (select syscolumns.domain
245                               from syscolumns, sysobjects
246                               where syscolumns.id = object_id(@tabname)
247                                   and syscolumns.name = @colname
248                                   and sysobjects.id = object_id(@tabname)
249                                   and uid = user_id()
250                                   and sysobjects.sysstat & 7 = 3)
251                           /* user table */
252                           and sequence = 0
253                           and status & 4096 = 4096))
254           begin
255               /*
256               ** 17855, "You cannot unbind a declared constraint. Use ALTER TABLE command."
257               */
258               raiserror 17855
259               return (1)
260           end
261   
262           /*
263           ** Check to see that the rule is not of declared type
264           */
265   
266           if ((@whichrule = "all") and
267                   exists (select * from sysprocedures
268                       where id = (select syscolumns.domain
269                               from syscolumns, sysobjects
270                               where syscolumns.id = object_id(@tabname)
271                                   and syscolumns.name = @colname
272                                   and isnull(syscolumns.accessrule, 0) = 0
273                                   and sysobjects.id = object_id(@tabname)
274                                   and uid = user_id()
275                                   and sysobjects.sysstat & 7 = 3)
276                           /* user table */
277                           and sequence = 0
278                           and status & 4096 = 4096))
279           begin
280               /*
281               ** 17855, "You cannot unbind a declared constraint. 
282               ** Use ALTER TABLE command."
283               */
284               raiserror 17855
285               return (1)
286           end
287   
288   
289           /*
290           ** If the status of the column reflects having more than one rule,
291           ** check if there indeed is more than one rules. If there is more
292           ** reset the domain field w/ a new rule.
293           */
294   
295           select @colid = syscolumns.colid
296           from syscolumns, sysobjects
297           where syscolumns.id = object_id(@tabname)
298               and syscolumns.name = @colname
299               and sysobjects.id = object_id(@tabname)
300               and uid = user_id()
301               and sysobjects.sysstat & 7 = 3
302   
303           select @tot_constr = count(*)
304           from sysconstraints
305           where tableid = object_id(@tabname)
306               and colid = @colid
307   
308           /*
309           **  Unbind it.
310           */
311           if (@tot_constr > 1 and (@whichrule = "all" or @whichrule is NULL))
312           begin
313               update syscolumns
314               set domain = (select max(constrid)
315                       from sysconstraints
316                       where tableid = object_id(@tabname)
317                           and colid = @colid)
318               from syscolumns, sysobjects
319               where syscolumns.id = object_id(@tabname)
320                   and syscolumns.name = @colname
321                   and sysobjects.id = object_id(@tabname)
322                   and uid = user_id()
323                   and sysobjects.sysstat & 7 = 3
324           end
325           else if (@tot_constr > 0 and (@whichrule = "all" or @whichrule is NULL))
326           begin
327               update syscolumns
328               set domain = (select max(constrid)
329                       from sysconstraints
330                       where tableid = object_id(@tabname)
331                           and colid = @colid),
332                   status = syscolumns.status & 239
333               from syscolumns, sysobjects
334               where syscolumns.id = object_id(@tabname)
335                   and syscolumns.name = @colname
336                   and sysobjects.id = object_id(@tabname)
337                   and uid = user_id()
338                   and sysobjects.sysstat & 7 = 3
339           end
340           else if (@whichrule = "all" or @whichrule is NULL)
341           begin
342               update syscolumns
343               set domain = 0
344               from syscolumns, sysobjects
345               where syscolumns.id = object_id(@tabname)
346                   and syscolumns.name = @colname
347                   and sysobjects.id = object_id(@tabname)
348                   and uid = user_id()
349                   and sysobjects.sysstat & 7 = 3
350           end
351   
352           if (@whichrule = "all" or @whichrule = "accessrule")
353           begin
354               update syscolumns
355               set accessrule = 0
356               from syscolumns, sysobjects
357               where syscolumns.id = object_id(@tabname)
358                   and syscolumns.name = @colname
359                   and sysobjects.id = object_id(@tabname)
360                   and uid = user_id()
361                   and sysobjects.sysstat & 7 = 3
362           end
363   
364           /*
365           ** If we just unbound an access rule from this column, zero out 
366           ** the accessrule column. Also, check all of the remaining
367           ** columns of this table to see if any have an access rule
368           ** on them - if not, remove the access-rule bit from
369           ** sysobjects for this table.
370           */
371           if (@access_rule > 0 and
372                   (@whichrule = "all" or @whichrule = "accessrule"))
373           begin
374               update syscolumns
375               set accessrule = 0
376               from syscolumns, sysobjects
377               where syscolumns.id = object_id(@tabname)
378                   and syscolumns.name = @colname
379                   and sysobjects.id = object_id(@tabname)
380                   and uid = user_id()
381                   and sysobjects.sysstat & 7 = 3
382   
383               /*
384               ** If there are other columns with an access rule,
385               ** reset @access_rule to 0, so that when we AND in
386               ** ~@access_rule to the sysobjects row for this table,
387               ** in the next update query, the 0x01000000 bit will
388               ** not get reset.
389               */
390               if exists (select * from syscolumns
391                       where id = object_id(@tabname)
392                           and isnull(accessrule, 0) > 0)
393   
394               begin
395                   select @access_rule = 0
396               end
397           end
398           /*
399           **  Since binding a rule is a schema change,
400           **  update schema count
401           **  for the object in the sysobjects table.
402           */
403   
404           /* 
405           ** This transaction also writes a log record for replicating the
406           ** invocation of this procedure. If logexec() fails, the transaction
407           ** is aborted.
408           **
409           ** IMPORTANT: The name rs_logexec is significant and is used by
410           ** Replication Server.
411           */
412           begin transaction rs_logexec
413   
414           if (schema_inc(object_id(@tabname), 0) != 1)
415           begin
416               /*
417               ** 17763, "The execution of the stored procedure '%1!'
418               **         in database '%2!' was aborted because there
419               **         was an error in updating the column
420               **         schemacnt in sysobjects."
421               */
422               select @dbname = db_name()
423               raiserror 17763, "sp_unbindrule", @dbname
424               rollback transaction rs_logexec
425               return (1)
426           end
427   
428           update sysobjects
429           set sysstat2 = sysstat2 & ~ @access_rule
430           from sysobjects
431           where id = object_id(@tabname)
432               and uid = user_id()
433   
434           /*
435           ** Write the log record to replicate this invocation 
436           ** of the stored procedure.
437           */
438           if (logexec() != 1)
439           begin
440               /*
441               ** 17756, "The execution of the stored procedure '%1!'
442               ** 	   in database '%2!' was aborted because there
443               ** 	   was an error in writing the replication log
444               **	   record."
445               */
446               select @dbname = db_name()
447               raiserror 17756, "sp_unbindrule", @dbname
448   
449               rollback transaction rs_logexec
450               return (1)
451           end
452   
453           commit transaction
454   
455           /*
456           ** 17850, "Rule unbound from table column."
457           */
458           exec sp_getmessage 17850, @msg output
459           print @msg
460           return (0)
461       end
462       else
463       begin
464           /*
465           **  We're unbinding to a user type.  In this case, the @objname
466           **  is really the name of the user datatype.
467           **  When we unbind to a user type, any existing columns get changed
468           **  to the new binding unless their current binding is not equal
469           **  to the current binding for the usertype or if they set the
470           **  @futureonly parameter to @futurevalue.
471           */
472           declare @oldrule int /* current rule for type */
473           declare @oldaccessrule int /* current access rule for type */
474           /*
475           **  Get the current rule for the datatype.
476           */
477           select @oldrule = domain, @oldaccessrule = accessrule
478           from systypes
479           where name = @objname
480               and uid = user_id()
481               and usertype > 100
482   
483           if @oldrule is null
484           begin
485               /*
486               ** 17844, "You do not own a user datatype of that name." 
487               */
488               /* Audit the failure to unbind a rule */
489               select @returncode =
490                   ad_hoc_audit(@eventnum, @mod_fail, NULL, db_name(),
491                       @objname, user_name(), 0, object_id(@objname)
492                   )
493               raiserror 17844
494               return (1)
495           end
496   
497           /* Audit the successful permission to unbind a rule */
498           select @returncode =
499               ad_hoc_audit(@eventnum, @mod_ok, NULL, db_name(),
500                   @objname, user_name(), 0, object_id(@objname)
501               )
502           if (@returncode != 0)
503           begin
504               /* 
505               ** 18293, "Auditing for '%1!' event has failed due to 
506               ** internal error. Contact a user with System Security 
507               ** Officer (SSO) role."
508               */
509               raiserror 18293, @eventnum
510               return (1)
511           end
512   
513           if (@whichrule = "accessrule")
514           begin
515               if ((@oldaccessrule is NULL) or (@oldaccessrule = 0))
516               begin
517                   /*
518                   ** 17852, "The specified user datatype has no rule."
519                   */
520                   raiserror 17852
521                   return (1)
522               end
523           end
524           else if (@whichrule = "all")
525           begin
526               if (((@oldaccessrule is NULL) or (@oldaccessrule = 0))
527                       and (@oldrule = 0))
528               begin
529                   /*
530                   ** 17852, "The specified user datatype has no rule."
531                   */
532                   raiserror 17852
533                   return (1)
534               end
535           end
536           else
537           begin
538               if (@oldrule = 0)
539               begin
540                   /*
541                   ** 17852, "The specified user datatype has no rule."
542                   */
543                   raiserror 17852
544                   return (1)
545               end
546           end
547   
548   
549           /* 
550           ** This transaction also writes a log record for
551           ** replicating the invocation of this procedure. If
552           ** logexec() fails, the transaction is aborted.
553           **
554           ** IMPORTANT: The name rs_logexec is significant and
555           ** is used by Replication Server.
556           */
557           begin transaction rs_logexec
558   
559           if (@whichrule = "all")
560           begin
561               update systypes
562               set domain = 0,
563                   accessrule = 0
564               from systypes
565               where name = @objname
566                   and uid = user_id()
567                   and usertype > 100
568           end
569           else if (@whichrule = "accessrule")
570           begin
571               update systypes
572               set accessrule = 0
573               from systypes
574               where name = @objname
575                   and uid = user_id()
576                   and usertype > 100
577           end
578           else
579           begin
580               update systypes
581               set domain = 0
582               from systypes
583               where name = @objname
584                   and uid = user_id()
585                   and usertype > 100
586           end
587   
588           /*
589           ** 17853, "Rule unbound from datatype."
590           */
591           exec sp_getmessage 17853, @msg output
592           print @msg
593   
594           /*
595           **  Now see if there are any columns with the usertype that
596           **  need the new binding.
597           */
598           select @rows_selected = 0
599           if isnull(@futureonly, "") != @futurevalue
600           begin
601               select @rows_selected = count(distinct syscolumns.id)
602               from syscolumns, systypes
603               where syscolumns.usertype = systypes.usertype
604                   and systypes.name = @objname
605                   and systypes.usertype > 100
606                   and systypes.uid = user_id()
607                   and
608                   (syscolumns.domain = @oldrule
609                       or
610                       syscolumns.accessrule = @oldaccessrule
611                   )
612   
613               if (@rows_selected > 0)
614               begin
615                   /*
616                   **  Update the table schema to indicate that something
617                   **  has changed in the table's schema.
618                   */
619   
620                   select @tmp = sum(schema_inc(s.id, 0))
621                   from sysobjects s
622                   where exists
623                           (select 1
624                           from syscolumns, systypes
625                           where s.id = syscolumns.id
626                               and syscolumns.usertype = systypes.usertype
627                               and systypes.name = @objname
628                               and systypes.usertype > 100
629                               and systypes.uid = user_id()
630                               and
631                               (syscolumns.domain = @oldrule
632                                   or
633                                   syscolumns.accessrule = @oldaccessrule
634                               ))
635   
636                   if (@rows_selected != @tmp)
637                   begin
638                       /*
639                       ** 17763, "The execution of the stored procedure '%1!'
640                       **         in database '%2!' was aborted because there
641                       **         was an error in updating the column
642                       **         schemacnt in sysobjects."
643                       */
644                       select @dbname = db_name()
645                       raiserror 17763, "sp_unbindrule", @dbname
646                       rollback transaction rs_logexec
647                       return (1)
648                   end
649   
650                   /*
651                   **  Update syscolumns with new binding.
652                   */
653                   if (@whichrule = "all")
654                   begin
655                       update syscolumns
656                       set domain = systypes.domain,
657                           accessrule = systypes.accessrule
658                       from syscolumns, systypes
659                       where syscolumns.usertype = systypes.usertype
660                           and systypes.name = @objname
661                           and systypes.usertype > 100
662                           and systypes.uid = user_id()
663                           and syscolumns.domain = @oldrule
664                   end
665                   else if (@whichrule = "accessrule")
666                   begin
667                       update syscolumns
668                       set accessrule = systypes.accessrule
669                       from syscolumns, systypes
670                       where syscolumns.usertype = systypes.usertype
671                           and systypes.name = @objname
672                           and systypes.usertype > 100
673                           and systypes.uid = user_id()
674                           and syscolumns.domain = @oldrule
675                   end
676                   else
677                   begin
678                       update syscolumns
679                       set domain = systypes.domain
680                       from syscolumns, systypes
681                       where syscolumns.usertype = systypes.usertype
682                           and systypes.name = @objname
683                           and systypes.usertype > 100
684                           and systypes.uid = user_id()
685                           and syscolumns.domain = @oldrule
686                   end
687   
688                   if (@access_rule > 0 and
689                           (@whichrule = "accessrule" or @whichrule = "all"))
690                   begin
691                       /*
692                       ** Now that we have removed the "access-rule"
693                       ** status bit from the syscolumns entry, check
694                       ** if any other columns of the tables that have
695                       ** this bit set still have access-rules: if not,
696                       ** reset the access-rule bit in the sysobjects
697                       ** row for these tables.
698                       */
699                       update sysobjects
700                       set sysstat2 = sysstat2 & ~ @access_rule
701                       from sysobjects, syscolumns, systypes
702                       where sysobjects.id = syscolumns.id
703                           and syscolumns.usertype = systypes.usertype
704                           and systypes.name = @objname
705                           and systypes.usertype > 100
706                           and systypes.uid = user_id()
707                           and not exists (select * from syscolumns
708                               where syscolumns.id = sysobjects.id
709                                   and isnull(syscolumns.accessrule, 0) > 0)
710                   end
711               end
712           end
713   
714           /*
715           ** Write the log record to replicate this invocation 
716           ** of the stored procedure.
717           */
718           if (logexec() != 1)
719           begin
720               /*
721               ** 17756, "The execution of the stored procedure
722               **         '%1!' in database '%2!' was aborted
723               **	    because there was an error in writing
724               **	    the replication log record."
725               */
726               select @dbname = db_name()
727               raiserror 17756, "sp_unbindrule", @dbname
728   
729               rollback transaction rs_logexec
730               return (1)
731           end
732   
733           commit transaction
734   
735           /*
736           ** 17854, "Columns of the user datatype specified 
737           ** had their rules unbound."
738           */
739           exec sp_getmessage 17854, @msg output
740           print @msg
741       end
742   
743       return (0)
744   
745   
746   


exec sp_procxmode 'sp_unbindrule', 'AnyMode'
go

Grant Execute on sp_unbindrule to public
go
DEFECTS
 MCTR 4 Conditional Begin Tran or Commit Tran 412
 MCTR 4 Conditional Begin Tran or Commit Tran 453
 MCTR 4 Conditional Begin Tran or Commit Tran 557
 MCTR 4 Conditional Begin Tran or Commit Tran 733
 MEST 4 Empty String will be replaced by Single Space 599
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 139
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 179
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 195
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 215
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 295
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 313
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 327
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 342
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 354
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 374
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 481
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 567
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 576
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 585
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 605
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 628
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 661
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 672
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 683
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 705
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 141
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 143
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 181
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 183
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 197
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 199
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 217
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 219
 MAW1 3 Warning message on %name% sybsystemprocs..sysprocedures.id: Warning message on sysprocedures 244
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 246
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 248
 MAW1 3 Warning message on %name% sybsystemprocs..sysprocedures.id: Warning message on sysprocedures 268
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 270
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 273
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 297
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 299
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 319
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 321
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 334
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 336
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 345
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 347
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 357
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 359
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 377
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 379
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 391
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 431
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 601
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 620
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 625
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 625
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 702
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 702
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 708
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 708
 MGTP 3 Grant to public sybsystemprocs..sp_unbindrule  
 MGTP 3 Grant to public sybsystemprocs..syscolumns  
 MGTP 3 Grant to public sybsystemprocs..sysconstraints  
 MGTP 3 Grant to public sybsystemprocs..sysobjects  
 MGTP 3 Grant to public sybsystemprocs..sysprocedures  
 MGTP 3 Grant to public sybsystemprocs..systypes  
 MNER 3 No Error Check should check @@error after update 313
 MNER 3 No Error Check should check @@error after update 327
 MNER 3 No Error Check should check @@error after update 342
 MNER 3 No Error Check should check @@error after update 354
 MNER 3 No Error Check should check @@error after update 374
 MNER 3 No Error Check should check @@error after update 428
 MNER 3 No Error Check should check return value of exec 458
 MNER 3 No Error Check should check @@error after update 561
 MNER 3 No Error Check should check @@error after update 571
 MNER 3 No Error Check should check @@error after update 580
 MNER 3 No Error Check should check return value of exec 591
 MNER 3 No Error Check should check @@error after update 655
 MNER 3 No Error Check should check @@error after update 667
 MNER 3 No Error Check should check @@error after update 678
 MNER 3 No Error Check should check @@error after update 699
 MNER 3 No Error Check should check return value of exec 739
 MUCO 3 Useless Code Useless Brackets 83
 MUCO 3 Useless Code Useless Brackets 89
 MUCO 3 Useless Code Useless Brackets 91
 MUCO 3 Useless Code Useless Brackets 98
 MUCO 3 Useless Code Useless Brackets 105
 MUCO 3 Useless Code Useless Brackets 107
 MUCO 3 Useless Code Useless Brackets 114
 MUCO 3 Useless Code Useless Brackets 157
 MUCO 3 Useless Code Useless Brackets 165
 MUCO 3 Useless Code Useless Brackets 173
 MUCO 3 Useless Code Useless Brackets 178
 MUCO 3 Useless Code Useless Brackets 192
 MUCO 3 Useless Code Useless Brackets 194
 MUCO 3 Useless Code Useless Brackets 212
 MUCO 3 Useless Code Useless Brackets 214
 MUCO 3 Useless Code Useless Brackets 234
 MUCO 3 Useless Code Useless Brackets 242
 MUCO 3 Useless Code Useless Brackets 259
 MUCO 3 Useless Code Useless Brackets 266
 MUCO 3 Useless Code Useless Brackets 285
 MUCO 3 Useless Code Useless Brackets 311
 MUCO 3 Useless Code Useless Brackets 325
 MUCO 3 Useless Code Useless Brackets 340
 MUCO 3 Useless Code Useless Brackets 352
 MUCO 3 Useless Code Useless Brackets 371
 MUCO 3 Useless Code Useless Brackets 414
 MUCO 3 Useless Code Useless Brackets 425
 MUCO 3 Useless Code Useless Brackets 438
 MUCO 3 Useless Code Useless Brackets 450
 MUCO 3 Useless Code Useless Brackets 460
 MUCO 3 Useless Code Useless Brackets 494
 MUCO 3 Useless Code Useless Brackets 502
 MUCO 3 Useless Code Useless Brackets 510
 MUCO 3 Useless Code Useless Brackets 513
 MUCO 3 Useless Code Useless Brackets 515
 MUCO 3 Useless Code Useless Brackets 521
 MUCO 3 Useless Code Useless Brackets 524
 MUCO 3 Useless Code Useless Brackets 526
 MUCO 3 Useless Code Useless Brackets 533
 MUCO 3 Useless Code Useless Brackets 538
 MUCO 3 Useless Code Useless Brackets 544
 MUCO 3 Useless Code Useless Brackets 559
 MUCO 3 Useless Code Useless Brackets 569
 MUCO 3 Useless Code Useless Brackets 613
 MUCO 3 Useless Code Useless Brackets 636
 MUCO 3 Useless Code Useless Brackets 647
 MUCO 3 Useless Code Useless Brackets 653
 MUCO 3 Useless Code Useless Brackets 665
 MUCO 3 Useless Code Useless Brackets 688
 MUCO 3 Useless Code Useless Brackets 718
 MUCO 3 Useless Code Useless Brackets 730
 MUCO 3 Useless Code Useless Brackets 743
 MUOT 3 Updates outside transaction 374
 MUUF 3 Update or Delete with Useless From Clause 428
 MUUF 3 Update or Delete with Useless From Clause 561
 MUUF 3 Update or Delete with Useless From Clause 571
 MUUF 3 Update or Delete with Useless From Clause 580
 QISO 3 Set isolation level 59
 QISO 3 Set isolation level 61
 QNAJ 3 Not using ANSI Inner Join 140
 QNAJ 3 Not using ANSI Inner Join 180
 QNAJ 3 Not using ANSI Inner Join 196
 QNAJ 3 Not using ANSI Inner Join 216
 QNAJ 3 Not using ANSI Inner Join 245
 QNAJ 3 Not using ANSI Inner Join 269
 QNAJ 3 Not using ANSI Inner Join 296
 QNAJ 3 Not using ANSI Inner Join 318
 QNAJ 3 Not using ANSI Inner Join 333
 QNAJ 3 Not using ANSI Inner Join 344
 QNAJ 3 Not using ANSI Inner Join 356
 QNAJ 3 Not using ANSI Inner Join 376
 QNAJ 3 Not using ANSI Inner Join 602
 QNAJ 3 Not using ANSI Inner Join 624
 QNAJ 3 Not using ANSI Inner Join 658
 QNAJ 3 Not using ANSI Inner Join 669
 QNAJ 3 Not using ANSI Inner Join 680
 QNAJ 3 Not using ANSI Inner Join 701
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 140
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 140
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 144
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 180
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 180
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 184
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 196
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 196
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 200
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 216
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 216
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 220
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 245
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 245
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 249
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 269
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 269
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 274
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 296
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 296
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 300
 QNUA 3 Should use Alias: Table sybsystemprocs..sysconstraints 315
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 318
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 322
 QNUA 3 Should use Alias: Table sybsystemprocs..sysconstraints 329
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 333
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 337
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 344
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 348
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 356
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 360
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 376
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 380
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 602
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 602
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 624
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 624
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 658
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 669
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 680
 QNUA 3 Should use Alias: Column sysstat2 should use alias sysobjects 700
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 701
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 701
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 707
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
141
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
181
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
197
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
217
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysprocedures.csysprocedures unique clustered
(id, number, type, sequence)
Intersection: {id, sequence}
244
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
246
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysprocedures.csysprocedures unique clustered
(id, number, type, sequence)
Intersection: {id, sequence}
268
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
270
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
297
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
319
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
334
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
345
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
357
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
377
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
391
 QSWV 3 Sarg with variable @tabname, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 305
 QSWV 3 Sarg with variable @colid, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 306
 QSWV 3 Sarg with variable @tabname, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 316
 QSWV 3 Sarg with variable @colid, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 317
 QSWV 3 Sarg with variable @tabname, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 330
 QSWV 3 Sarg with variable @colid, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 331
 MSUB 2 Subquery Marker 139
 MSUB 2 Subquery Marker 179
 MSUB 2 Subquery Marker 195
 MSUB 2 Subquery Marker 215
 MSUB 2 Subquery Marker 243
 MSUB 2 Subquery Marker 244
 MSUB 2 Subquery Marker 267
 MSUB 2 Subquery Marker 268
 MSUB 2 Subquery Marker 314
 MSUB 2 Subquery Marker 328
 MSUB 2 Subquery Marker 390
 MSUC 2 Correlated Subquery Marker 623
 MSUC 2 Correlated Subquery Marker 707
 MTR1 2 Metrics: Comments Ratio Comments: 37% 25
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 92 = 111dec - 21exi + 2 25
 MTR3 2 Metrics: Query Complexity Complexity: 398 25
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, t=sybsystemprocs..systypes} 0 601
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, o=sybsystemprocs..sysobjects, t=sybsystemprocs..systypes} 0 623
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, t=sybsystemprocs..systypes} 0 655
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, t=sybsystemprocs..systypes} 0 667
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, t=sybsystemprocs..systypes} 0 678
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, o=sybsystemprocs..sysobjects, t=sybsystemprocs..systypes} 0 699
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, o=sybsystemprocs..sysobjects} 0 707

DEPENDENCIES
PROCS AND TABLES USED
reads table sybsystemprocs..sysprocedures  
calls proc sybsystemprocs..sp_getmessage  
   reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  
read_writes table sybsystemprocs..sysobjects  
reads table sybsystemprocs..sysconstraints  
read_writes table sybsystemprocs..systypes  
read_writes table sybsystemprocs..syscolumns