DatabaseProcApplicationCreatedLinks
sybsystemprocssp_help  14 déc. 14Defects Propagation Dependencies

1     /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
2     /*	4.8	1.1	06/14/90	sproc/src/help */
3     /*
4     ** Messages for "sp_help"               17570
5     **
6     ** 17460, "Object must be in the current database."
7     ** 17461, "Object does not exist in this database."
8     ** 17570, "Operating System File"
9     ** 17571, "---------------------"
10    ** 17573, "Object is Remote/External"
11    ** 17574, "-------------------------"
12    ** 17575, "Object existed prior to Omni"
13    ** 17576, "Lock scheme is Allpages" 
14    ** 17577, "Lock scheme is Datapages"
15    ** 17578, "Lock scheme is Datarows" 
16    ** 17579, "Lock scheme Unknown or Corrupted" 
17    ** 17581, "Trigger is disabled."
18    ** 17582, "Trigger is enabled."
19    ** 18571, "The attribute '%1!' is not applicable to tables with allpages lock scheme."
20    ** 17589, "computed column"
21    ** 19456, "Object is a computed column in table '%1!'."
22    ** 19457, "Object is a function-based index key in table '%1!'."
23    */
24    
25    /*
26    ** IMPORTANT NOTE:
27    ** This stored procedure uses the built-in function object_id() in the
28    ** where clause of a select query. If you intend to change this query
29    ** or use the object_id() or db_id() builtin in this procedure, please read the
30    ** READ.ME file in the $DBMS/generic/sproc directory to ensure that the rules
31    ** pertaining to object-id's and db-id's outlined there, are followed.
32    */
33    
34    create or replace procedure sp_help
35        @objname varchar(767) = NULL /* object name we're after */
36    as
37    
38        declare @typeid int /* type of object in systypes */
39        declare @basetypeid int /* base type in systypes */
40        declare @lenfactor int /* length factor */
41        declare @sysstat smallint /* the type of the object */
42        declare @OS_file varchar(255) /* physical file for ext tab */
43        declare @msg varchar(1024)
44        declare @sptlang int
45        declare @len1 int, @len2 int, @len3 int, @len4 int, @len5 int, @len6 int, @sysstat2 int,
46            @valstat2 int
47        declare @sqltext varchar(1024) /* SQL to execute using execute
48        ** immediate. */
49        declare @and_access int /* cache bits in OBJECT.sysstat2 */
50        declare @or_access int /* cache bits in OBJECT.sysstat2 */
51    
52        declare @sqlj_proc int /* indicates a sqlj proc */
53        declare @opt_ind_status int /* status of optimistic index lock */
54        declare @opt_ind_value int /* user input value of optimistic index lock */
55        declare @opt_ind_lock int /* Server constant for optimistic index lock */
56        declare @cached_ind_val int /* user input value of cached index root page */
57        declare @tab_cached_ind int /* Server constant for cached index root page */
58        declare @opt_text_dealloc int
59        declare @opt_text_value int
60        declare @opt_ind2_ascinserts int /* Server constant for ascinserts */
61        declare @encrypted_col int /* indicates encrypted col */
62            , @decrypt_def int /* indicates decrypt default col */
63            , @inrowlob int /* status2: whether column is LOB 'in row' */
64            , @thiskey varchar(30) /* index key column of 
65        ** virtually hashed table. 
66        */
67        declare @notruncate int /* indicates no truncation for varbinary columns */
68        declare @indid int
69        declare @new_char_value varchar(255) /* hash factors of virtually 
70        ** hashed table. 
71        */
72        declare @num_keys int /* #index keys columns. */
73        declare @key_count int,
74            @msgnum int,
75            @valstat3 int,
76            @valstat4 int,
77            @sysstat3 int,
78            @sysstat4 int,
79            @sep varchar(2),
80            @sysopt_name varchar(100)
81        declare @tab_lob_cmplvl tinyint /* LOB compression level for table */
82        declare @objtype char(2) /* object type in sysobjects */
83        declare @db_stat4 int
84        declare @db_dealloc_ftp int /* Dealloc FTP after NULL update */
85        declare @tab_keep_ftp int /* Keep FTP after NULL update */
86        declare @tab_dealloc_ftp int /* Dealloc FTP after NULL update */
87        declare @Object_status varchar(255)
88        declare @tab_erd int /* Erase Residual Data */
89        declare @tab_volatile int /* Table is volatile table */
90        declare @sysconstr_stat int /* sysconstraints.status */
91    
92        if @@trancount = 0
93        begin
94            set chained off
95        end
96    
97        set transaction isolation level 1
98    
99        select @sptlang = @@langid
100   
101       if @@langid != 0
102       begin
103           if not exists (
104                   select * from master.dbo.sysmessages where error
105                       between 17100 and 17109
106                       and langid = @@langid)
107               select @sptlang = 0
108       end
109   
110       set nocount on
111   
112       /*
113       **  If no @objname given, give a little info about all objects.
114       **  Note: 0x80f is the mask for sysstats (=2063decimal).
115       ** 	  800 is used by Stratus for external tables.
116       */
117   
118       select @sqlj_proc = hextoint("0x2000000")
119   
120       if @objname is NULL
121       begin -- {
122           /*
123           ** Instead of Triggers are sub_types of trigger
124           ** type; so first check for sysstat to be 8, then build the
125           ** prefix of "instead of" for the trigger if needed.
126           */
127           select Name = o.name,
128               Owner = user_name(uid),
129               Object_type = (case
130                   when ((o.sysstat & 15) = 8)
131                   then (case
132                       when (o.type = "IT")
133                       then "instead of "
134                       else null
135                   end)
136                   else null
137               end
138               )
139               + (m.description + x.name)
140           into #sphelp1rs
141           from sysobjects o, master.dbo.spt_values v,
142               master.dbo.spt_values x, master.dbo.sysmessages m
143           where o.sysstat & 2063 = v.number
144               and ((v.type = "O" and
145                       (o.type != "XP" and ((o.sysstat2 & @sqlj_proc) = 0
146                               or o.type = "U" or o.type = "S")) and
147                       (o.type != "RS")) /* precomputed result set */
148                   or (v.type = "O1" and o.type = "XP") or
149                   (v.type = "O2" and (o.sysstat2 & @sqlj_proc) != 0
150                       and o.type != "U" and o.type != "S")
151                   or (v.type = "O1" and o.type = "RS") /* precomputed result set */
152                   or (v.type = "EK" and o.type = "EK"))
153               and v.msgnum = m.error
154               and isnull(m.langid, 0) = @sptlang
155               and ((m.error between 17100 and 17109) or
156                   (m.error between 17587 and 17589) or
157                   (m.error between 18903 and 18904) or
158                   (m.error = 17588 or m.error = 17139
159                       or m.error = 17015))
160   
161               and x.type = "R"
162               and o.userstat & - 32768 = x.number
163           exec sp_autoformat @fulltabname = #sphelp1rs,
164               @orderby = "order by 3 desc, 1 asc"
165           drop table #sphelp1rs
166   
167           select User_type = s.name,
168               Storage_type = st.name,
169               Length = s.length,
170               Nulls = s.allownulls,
171               Default_name = object_name(s.tdefault),
172               Rule_name = object_name(s.domain),
173               Access_Rule_name = object_name(s.accessrule)
174           into #sphelp2rs
175           from systypes s, systypes st
176           where s.type = st.type
177               and s.usertype > 99
178               and st.name not in ("sysname", "longsysname", "nchar", "nvarchar")
179               and st.usertype < 100
180           exec sp_autoformat @fulltabname = #sphelp2rs,
181               @orderby = "order by 1"
182           drop table #sphelp2rs
183   
184           /* Display list of Java classes installed in this database */
185           print ""
186           select Class_name = x.xtname,
187               Jar_name = isnull(j.jname, '')
188           into #sphelp3rs
189           from sysxtypes x, sysjars j
190           where x.xtcontainer *= j.jid
191           exec sp_autoformat @fulltabname = #sphelp3rs,
192               @orderby = "order by 1"
193           drop table #sphelp3rs
194   
195           /* Display list of Java JARs installed in this database */
196           print ""
197           exec sp_autoformat @fulltabname = sysjars,
198               @selectlist = "'Jar_name' = jname",
199               @orderby = "order by 1"
200           print ""
201           return (0)
202       end -- }
203   
204       /*
205       ** If this is a 4-part object name, mangle the name appropriately.
206       ** [Note: this must be run in tempdb for successful results.]
207       */
208       if @objname like "%.%.%.%"
209       begin
210           select @objname = str_replace(@objname, '.', '_')
211       end
212   
213       /*
214       **  Make sure the @objname is local to the current database.
215       */
216       if @objname like "%.%.%" and
217           substring(@objname, 1, charindex(".", @objname) - 1) != db_name()
218       begin
219           /* 17460, "Object must be in the current database." */
220           raiserror 17460
221           return (1)
222       end
223   
224       /*
225       **  Now check to see if the @objname is in sysobjects.  It has to be either
226       **  in sysobjects or systypes.
227       */
228       if not exists (select *
229               from sysobjects
230               where id = object_id(@objname))
231   
232       /*
233       **  It wasn't in sysobjects so we'll check in systypes.
234       */
235       begin -- {
236           select @typeid = usertype, @basetypeid = type
237           from systypes
238           where name = @objname
239   
240           /*
241           **  Time to give up -- @objname is not in sysobjects or systypes.
242           */
243           if @typeid is NULL
244           begin
245               /* 17461, "Object does not exist in this database." */
246               raiserror 17461
247               return (1)
248           end
249   
250           /*
251           ** Get length factor: types based on unichar/univarchar
252           ** are 2 bytes per character.
253           */
254           if (@basetypeid in (select type from systypes where
255                           name in ('unichar', 'univarchar')))
256               select @lenfactor = @@unicharsize
257           else
258               select @lenfactor = 1
259   
260           /*
261           ** Print help about a data type
262           */
263   
264           select Type_name = s.name,
265               Storage_type = st.name,
266               Length = s.length / @lenfactor,
267               Nulls = s.allownulls,
268               Prec = s.prec,
269               Scale = s.scale,
270               Default_name = object_name(s.tdefault),
271               Rule_name = object_name(s.domain),
272               Access_Rule_name = object_name(s.accessrule),
273               Ident = s.ident
274           into #sphelp4rs
275           from systypes s, systypes st
276           where s.usertype = @typeid
277               and s.type = st.type
278               and st.name not in ("timestamp", "sysname", "longsysname", "nchar", "nvarchar")
279               and st.usertype < 100
280   
281           exec sp_autoformat @fulltabname = #sphelp4rs,
282               @selectlist = "Type_name, Storage_type,Length,Prec,Scale,Nulls,Default_name,Rule_name,Access_Rule_name,'Identity' = Ident"
283           drop table #sphelp4rs
284   
285           return (0)
286       end -- }
287   
288       /*
289       **  It's in sysobjects so print out the information.
290       */
291   
292       /* 
293       ** Define status bit values for O2_ACCESS_CONTROL
294       ** and O2_OR_ACCESS_CONTROL.
295       */
296       select @and_access = hextoint("0x1000000"),
297           @or_access = hextoint("0x4000000")
298   
299       select Name = o.name,
300           Owner = user_name(uid),
301   
302           /*
303           ** Decode object type, and figure out if its an access rule
304           ** type. Access rules are sub-types of the rule type; so
305           ** first check for sysstat to be 7. Build the prefix of
306           ** 'AND access', or 'OR access', or '' strings. The prefix
307           ** will be concatenated to the string 'rule' as obtained
308           ** from the other tables.
309           ** Meanwhile, Instead of Triggers are sub_types of trigger
310           ** type; so first check for sysstat to be 8, then build the
311           ** prefix of "instead of" for the trigger if needed.
312           */
313           Object_type = (case
314               when ((o.sysstat & 15) = 7)
315               then (case
316                   when (((o.sysstat2 & @and_access) > 0)
317                           and ((o.sysstat2 & @or_access) > 0))
318                   then "OR access"
319                   when ((o.sysstat2 & @and_access) > 0)
320                   then "AND access"
321                   else null
322               end
323               )
324               when ((o.sysstat & 15) = 8)
325               then (case
326                   when (o.type = "IT")
327                   then "instead of "
328                   else null
329               end)
330               else null
331           end
332           )
333           + (m.description + x.name)
334           , Object_status = convert(varchar(255), ' ')
335           , Create_date = o.crdate
336       into #sphelp5rs
337       from sysobjects o, master.dbo.spt_values v,
338           master.dbo.spt_values x, master.dbo.sysmessages m
339       where o.id = object_id(@objname)
340           and o.sysstat & 2063 = v.number
341           and ((v.type = "O" and
342                   (o.type != "XP" and ((o.sysstat2 & @sqlj_proc) = 0
343                           or o.type = "U" or o.type = "S"))
344                   and (o.type != "RS")) or /* precomputed result set */
345               (v.type = "O1" and o.type = "XP") or
346               (v.type = "O2" and (o.sysstat2 & @sqlj_proc) != 0
347                   and o.type != "U" and o.type != "S") or
348               (v.type = "O1" and o.type = "RS") or /* precomputed result set */
349               (v.type = "EK" and o.type = "EK"))
350           and v.msgnum = m.error
351           and isnull(m.langid, 0) = @sptlang
352           and ((m.error between 17100 and 17199) or
353               (m.error between 17587 and 17589) or
354               (m.error between 18903 and 18904) or
355               (m.error = 17588 or m.error = 17015))
356           and x.type = "R"
357           and o.userstat & - 32768 = x.number
358   
359       /*
360       ** Set Object_status based on sysstat2 to show any special status the object may have.
361       ** Currently only object status 'deallocate first text page' or 'keep first text page'
362       ** would be displayed based on both table level (by sp_chgattribute) and db level (by
363       ** sp_dboption) settings as below.
364       **
365       ** 'deallocate first text page' will be displayed when
366       **	o column sysstat2 of sysobjects entry has value 536870912
367       **	o or column sysstat2 of sysobjects entry neither has value 536870912 nor
368       **	  -2147483648, but column status4 of sysdatabases entry (for current
369       **	  database) has value -2147483648.
370       **
371       ** otherwise, 'keep first text page' will be displayed.
372       **
373       ** Table level setting for option dealloc_first_txtpg (sysstat2 in sysobjects)
374       **	0x2000000 ---- 536870912, deallocate first text page after NULL update
375       **	0x8000000 ---- -2147483648, keep first text page after NULL update
376       **
377       ** DB level setting for option 'deallocate first text page' (status4 in sysdatabases)
378       **	0x8000000 ---- -2147483648, deallocate first text page after NULL update
379       */
380       select @db_dealloc_ftp = hextoint('0x80000000')
381       select @tab_dealloc_ftp = hextoint('0x20000000')
382       select @tab_keep_ftp = hextoint('0x80000000')
383       select @tab_erd = hextoint('0x00000002')
384       select @tab_volatile = hextoint('0x00000008')
385   
386       select @sysstat2 = sysstat2, @sysstat4 = sysstat4, @objtype = type
387       from sysobjects
388       where id = object_id(@objname)
389   
390       /*
391       ** Only check user tables
392       */
393       if (@objtype = 'U')
394       begin
395           select @db_stat4 = status4 from master.dbo.sysdatabases
396           where dbid = db_id()
397   
398           if ((@sysstat2 & @tab_dealloc_ftp != 0) or
399                   ((@sysstat2 & @tab_keep_ftp = 0) and (@db_stat4 & @db_dealloc_ftp != 0)))
400           begin
401               select @valstat2 = @tab_dealloc_ftp
402           end
403           else
404           begin
405               select @valstat2 = @tab_keep_ftp
406           end
407   
408           if (@sysstat4 & @tab_volatile != 0)
409           begin
410               print "This table is VOLATILE table."
411           end
412   
413           if (@sysstat4 & @tab_erd != 0)
414           begin
415               select @valstat4 = @tab_erd
416           end
417   
418           select @msgnum = msgnum, @sysopt_name = name, @sep = ''
419           from master.dbo.spt_values
420           where type = 'O2' and number = @valstat2
421   
422           if (@msgnum != 17119)
423           begin
424               select @sysopt_name = isnull(description, @sysopt_name)
425               from master.dbo.sysmessages
426               where error = @msgnum
427                   and isnull(langid, 0) = @sptlang
428   
429               update #sphelp5rs
430               set Object_status = ltrim(Object_status + @sep + @sysopt_name)
431               from #sphelp5rs a, sysobjects o
432               where a.Name = o.name
433                   and o.sysstat & 15 = 3
434                   and o.id = object_id(@objname)
435           end
436   
437           if (@valstat4 is not null)
438           begin
439               if (@sysopt_name is not null)
440               begin
441                   select @sep = ', '
442               end
443               else
444               begin
445                   select @sep = ''
446               end
447   
448               select @msgnum = msgnum, @sysopt_name = name
449               from master.dbo.spt_values
450               where type = 'O4' and number = @valstat4
451   
452               select @sysopt_name = isnull(description, @sysopt_name)
453               from master.dbo.sysmessages
454               where error = @msgnum
455                   and isnull(langid, 0) = @sptlang
456   
457               update #sphelp5rs
458               set Object_status = ltrim(Object_status + @sep + @sysopt_name)
459               from #sphelp5rs a, sysobjects o
460               where a.Name = o.name
461                   and o.sysstat & 15 = 3
462                   and o.id = object_id(@objname)
463           end
464   
465       end -- }
466   
467       /* Set Object_status based on sysstat3 to show any special status the object may have */
468       select @Object_status = Object_status
469       from #sphelp5rs a, sysobjects o
470       where a.Name = o.name
471           and o.id = object_id(@objname)
472   
473       if (@Object_status != "")
474       begin
475           select @sep = ', '
476       end
477       else
478       begin
479           select @sep = ''
480       end
481   
482       select @sysstat3 = sysstat3, @objtype = type
483       from sysobjects
484       where id = object_id(@objname)
485   
486       select @valstat3 = min(number)
487       from master.dbo.spt_values
488       where type = 'O3'
489           and number > 0
490           and number & @sysstat3 = number
491   
492       while (@valstat3 is not null)
493       begin -- {
494           select @msgnum = msgnum, @sysopt_name = name
495           from master.dbo.spt_values
496           where type = 'O3' and number = @valstat3
497   
498           /* We do not allow PRS objects to be defined on other PRS
499           ** objects. Even if we plan to support this in future, this
500           ** will be a major design change and sp_help will have to be
501           ** updated accordingly to allow that. The bit 0x40 in sysstat3
502           ** is currently overridden to check if PRS objects are defined
503           ** on any object.
504           */
505           if not (@objtype = 'RS' and @msgnum = 17119)
506           begin
507               select @sysopt_name = isnull(description, @sysopt_name)
508               from master.dbo.sysmessages
509               where error = @msgnum
510                   and isnull(langid, 0) = @sptlang
511   
512               update #sphelp5rs
513               set Object_status = ltrim(Object_status + @sep + @sysopt_name)
514               from #sphelp5rs a, sysobjects o
515               where a.Name = o.name
516                   and o.sysstat & 15 in (3, 4)
517                   and o.sysstat3 & @valstat3 = @valstat3
518           end
519   
520           select @valstat3 = min(number), @sep = ', '
521           from master.dbo.spt_values
522           where type = 'O3'
523               and number > @valstat3
524               and number & @sysstat3 = number
525       end -- }
526   
527       /* Set Object_status to show any special status the object may have */
528       select @sysstat4 = sysstat4, @objtype = type
529       from sysobjects
530       where id = object_id(@objname)
531   
532       select @valstat4 = min(number)
533       from master.dbo.spt_values
534       where type = 'O4'
535           and number > 0
536           and number & @sysstat4 = number
537   
538       while (@valstat4 is not null)
539       begin -- {
540           select @msgnum = msgnum, @sysopt_name = name
541           from master.dbo.spt_values
542           where type = 'O4' and number = @valstat4
543   
544           select @valstat4 = min(number), @sep = ', '
545           from master.dbo.spt_values
546           where type = 'O4'
547               and number > @valstat4
548               and number & @sysstat4 = number
549       end -- }
550   
551       /*
552       ** If the object type is precomputed result set then set Object_status
553       ** information with the following properties:
554       ** a. Refresh Policy: immediate/manual
555       ** b. State: enabled/disabled
556       ** c. QRW State: enabled/disabled for QRW
557       */
558       if @objtype = 'RS'
559       begin -- {
560           /* #sphelp5rs will only have 1 row corresponding to a PRS */
561           update #sphelp5rs
562           set
563               Object_status =
564               /* Save existing Object_status information */
565               (case
566                   when (Object_status != "") then Object_status + ", "
567                   else null
568               end) +
569               /* refresh policy */
570               (case
571                   when ((@sysstat3 & 8) = 8) then "manual"
572                   when ((@sysstat3 & 16) = 16) then "immediate"
573               end) + ", " +
574               /* state */
575               (case
576                   when ((@sysstat3 & 32) = 32) then "disabled"
577                   else "enabled"
578               end) + ", " +
579               /* query rewrite state */
580               (case
581                   when ((@sysstat3 & 64) = 64) then "disabled for QRW"
582                   else "enabled for QRW"
583               end)
584       end -- }
585   
586       update #sphelp5rs
587       set Object_status = (select description
588               from master.dbo.sysmessages
589               where error = 17661
590                   and isnull(langid, 0) = @sptlang)
591       where datalength(Object_status) < 2
592   
593       exec sp_autoformat @fulltabname = #sphelp5rs
594       drop table #sphelp5rs
595   
596   
597       /*
598       **  Objects have the following value for sysstat & 15:
599       **	0 - any/illegal object 
600       **	1 - system table
601       **	2 - view
602       **	3 - user table
603       **	4 - sproc
604       **	5 - predicate
605       **	6 - default
606       **	7 - rule
607       **	8 - trigger
608       **	9 - referential constraint
609       **	10 - sql function  
610       **      11 - extended type
611       **      12 - sqlj function
612       **      13 - computed column
613       **      14 - partition condition
614       **      15 - encryption key
615       **	
616       **
617       **  If the object is a system table, view, or user table, we want to check
618       **  out the objects columns here.
619       */
620   
621       select @sysstat = sysstat, @sysstat2 = sysstat2
622       from sysobjects
623       where id = object_id(@objname)
624   
625       /*
626       **  Fix of bug 91669:
627       **  For the current design, a view having nameless column may be created,
628       **  e.g. create view view1 as select sum(column1) from table1. 
629       **  In this case, c.name is NULL. Using builtin function isnull() to  
630       **  make the following query work. 
631       */
632   
633       select @encrypted_col = hextoint("0x00000080")
634           , @decrypt_def = hextoint("0x00001000")
635           , @inrowlob = hextoint("0x00040000")
636           , @notruncate = hextoint("0x00200000")
637   
638       -- Report on the following "table" objects:
639       -- 	1: System tables
640       -- 	2: Views
641       -- 	3: User tables
642       --
643       if (@sysstat & 15) in (1, 2, 3)
644       begin
645           select Column_name = isnull(c.name, 'NULL'),
646               Col_order = colid,
647               Type = isnull(convert(char(30), x.xtname),
648                   isnull(convert(char(30),
649                       get_xtypename(c.xtype, c.xdbid)),
650                       t.name)),
651               Length = c.length,
652               In_row_Len = c.inrowlen,
653               Prec = c.prec,
654               Scale = c.scale,
655               Nulls = convert(bit, (c.status & 8)),
656               Not_compressed = convert(bit, (isnull(c.status2, 0) & 131072)),
657               Lob_compression_level = c.lobcomp_lvl,
658               Default_name = object_name(c.cdefault),
659               Rule_name = object_name(c.domain),
660               Access_Rule_name = object_name(c.accessrule),
661               Computed_Column_object =
662               case when (c.status3 & 1) = 1
663                   then object_name(c.computedcol) +
664                   " (functional index key)"
665                   when (c.status2 & 32) = 32
666                   then object_name(c.computedcol) + " (materialized)"
667                   when (c.status2 & 16) = 16
668                   then object_name(c.computedcol) + " (virtual)"
669                   else object_name(c.computedcol)
670               end,
671               rtype = t.type, utype = t.usertype, xtype = c.xtype,
672               Ident = convert(bit, (c.status & 0x80)),
673               Encrypted =
674               case when (c.status2 is null) then 0
675                   when (c.status2 & @encrypted_col) > 0 then 1
676               end,
677               Decrypt_Default_name =
678               case when (c.status2 is null) then NULL
679                   when (c.status2 & @decrypt_def) > 0 then
680                       (select object_name(a.object)
681                       from sysattributes a
682                       where a.class = 25
683                           and a.attribute = 1
684                           and a.object_info1 = c.id
685                           and a.object_info2 = c.colid)
686                   else NULL
687               end,
688               Object_storage =
689               case
690                   when ((isnull(c.status2, 0) & @inrowlob) != 0)
691                   then "in row"
692                   when (c.xstatus is null) then NULL
693                   when (c.xstatus & 1) = 1 then "off row"
694                   else "in row "
695               end,
696               Varbinary_is_truncated =
697               case when (c.status2 is null) then NULL
698                   when (c.status2 & @notruncate) > 0 then 0
699                   else 1
700               end
701           into #helptype
702           from syscolumns c, systypes t, sysxtypes x
703           where c.id = object_id(@objname)
704               and c.usertype *= t.usertype
705               and c.xtype *= x.xtid
706   
707           /* 
708           ** We truncate extended type names >30 characters to 30,
709           ** and print them with a trailing "+" character.
710           */
711           update #helptype
712           set Type = substring(Type, 1, 29) + "+"
713           where xtype is not null
714               and substring(Type, 29, 1) != " "
715   
716           /* Handle National Characters */
717           update #helptype
718           set Length = Length / @@ncharsize
719           where (rtype = 47 and utype = 24)
720               or (rtype = 39 and utype = 25)
721   
722           /* Handle unichar/univarchar */
723           update #helptype
724           set Length = Length / @@unicharsize
725           where rtype in (select type from systypes
726                   where name in ('unichar', 'univarchar'))
727   
728           /* Handle unsigned types by outputing user syntax */
729           update #helptype
730           set Type = "unsigned " +
731               substring(Type, charindex("u", Type) + 1, 30)
732           where utype in (44, 45, 46)
733   
734           /*
735           ** Construct the SQL query against #helptype. Be careful not to
736           ** exceed 255 characters, or the string will get truncated.
737           */
738           select @sqltext = "Column_name,Type, Length"
739   
740           /* Display in-row length only if there are any in-row LOBs */
741           if exists (select 1 from #helptype
742                   where In_row_Len is not null)
743           begin
744               /* Convert bytes to unichars for length of unitext */
745               update #helptype
746               set In_row_Len = In_row_Len / @@unicharsize
747               where rtype in (select type from systypes
748                       where name = 'unitext')
749   
750               select @sqltext = @sqltext + ",In_row_Len "
751           end
752   
753           select @sqltext = @sqltext
754               + ", Prec,Scale,Nulls,Not_compressed,Default_name,Rule_name,Access_Rule_name,Computed_Column_object,'Identity' = Ident"
755   
756           /* Display the Object_storage only if there are object columns. */
757           if exists (select * from #helptype
758                   where Object_storage is not null)
759           begin
760               select @sqltext = @sqltext + ", Object_storage "
761           end
762   
763           /* 
764           ** Display the Encrypted column status only if there are encrypted
765           ** columns.
766           */
767           if exists (select * from #helptype
768                   where Encrypted != 0)
769           begin
770               select @sqltext = @sqltext + ", Encrypted "
771           end
772   
773   
774           /* 
775           ** Display the Decrypt_Default_name only if there 
776           ** are encrypted columns that have decrypt default values
777           */
778           if exists (select * from #helptype
779                   where Decrypt_Default_name is not null)
780           begin
781               select @sqltext = @sqltext + ", Decrypt_Default_name"
782           end
783   
784           /* 
785           ** Display Lob compression level only if there are compressed LOB
786           ** columns.
787           */
788           if exists (select * from #helptype
789                   where Lob_compression_level is not null)
790           begin
791               select @sqltext = @sqltext + ", Lob_compression_level"
792           end
793   
794           /* 
795           ** Display the varbinary truncation only if there 
796           ** is any varbinary column.
797           */
798           if exists (select * from #helptype where Type = "varbinary" or (Type = "binary" and Nulls = 1))
799           begin
800               select @sqltext = @sqltext + ", Varbinary_is_truncated"
801   
802               /* Update the field non-varbinary types */
803               update #helptype set Varbinary_is_truncated = NULL
804               where (Type != "varbinary" and (Type != "binary" or Nulls = 0))
805                   or Computed_Column_object is not null
806           end
807   
808           exec sp_autoformat @fulltabname = #helptype,
809               @selectlist = @sqltext,
810               @orderby = "order by Col_order asc"
811   
812           drop table #helptype
813       end
814   
815       /* 
816       ** If this is a table object that has computed columns, display the
817       ** computed column information.
818       */
819       if (@sysstat & 15) in (1, 3)
820       begin
821           if exists (select 1 from syscolumns where id = object_id(@objname)
822                       and computedcol is not null and (status3 & 1) != 1)
823           begin
824               print ""
825               execute dbo.sp_helpcomputedcolumn @objname, 0
826           end
827       end
828   
829       /*
830       **  For procedures and sqlj functions, the parameters of the procedures 
831       **  are stored in syscolumns.
832       */
833       if @sysstat & 15 in (4, 10, 12)
834       begin
835           exec sp_help_params @objname
836       end
837   
838       /*
839       **  If the object is an external table, show which OS file it's using.
840       */
841       if @sysstat & 2063 = 2051
842       begin
843           select @OS_file = name from sysindexes
844           where id = object_id(@objname)
845               and indid in (0, 1)
846           /*
847           ** 17570, "Operating System File"
848           ** 17571, "---------------------"
849           */
850           print ""
851           exec sp_getmessage 17570, @msg out
852           print @msg
853           exec sp_getmessage 17571, @msg out
854           print @msg
855           print @OS_file
856           print ""
857       end
858       /*
859       **  If the object is an Omni-managed table, show its storage location.
860       */
861       if (@sysstat2 & 1024 = 1024)
862       begin
863           declare @dbname varchar(255),
864               @site varchar(255),
865               @owner varchar(255),
866               @tabname varchar(255),
867               @retcode int
868   
869           exec @retcode = sp_namecrack @objname, @site output, @dbname output,
870               @owner output, @tabname output
871   
872           select @OS_file = char_value from sysattributes
873           where class = 9 and attribute = 1 and
874               object_cinfo = @tabname
875   
876           /*
877           **  17573, "Object is Remote/External"
878           **  17574, "-------------------------"
879           */
880           print ""
881           exec sp_getmessage 17573, @msg out
882           print @msg
883           exec sp_getmessage 17574, @msg out
884           print @msg
885           print @OS_file
886           print ""
887   
888           if (@sysstat2 & 2048 = 2048)
889           begin
890               /*
891               ** 17575, "Object existed prior to Omni"
892               */
893               exec sp_getmessage 17575, @msg out
894               print @msg
895               print ""
896           end
897       end
898   
899       /* 
900       **  If the object is a table, display sysattributes information
901       **  if there is any.  It could be in the current database under
902       **  type "T".
903       */
904   
905       if @sysstat & 15 in (1, 3)
906       begin
907           /*  Create temporary table for sysattributes data */
908           create table #sphelpattr
909           (
910               class varchar(255),
911               class_id smallint,
912               attribute varchar(255),
913               attribute_id smallint,
914               int_value int NULL,
915               char_value varchar(255) NULL,
916               comments varchar(255) NULL
917           )
918   
919           /* 
920           **  The join with master..sysattributes here is to
921           **  get the string descriptions for the class and attribute.
922           **  These should never be more than 30 chars, so it's okay to
923           **  truncate them.
924           */
925   
926           insert #sphelpattr(class, class_id, attribute, attribute_id, int_value,
927               char_value, comments)
928           select c.char_value,
929               t.class,
930               a.char_value,
931               t.attribute,
932               t.int_value, t.char_value, t.comments
933           from sysattributes t, master.dbo.sysattributes c,
934               master.dbo.sysattributes a
935           where t.object_type = "T"
936               and t.object = object_id(@objname)
937               and c.class = 0 and c.attribute = 0
938               and a.class = 0 and a.attribute = 1
939               and t.class = c.object
940               and t.class = a.object
941               and t.attribute = a.object_info1
942   
943           /*
944           ** If the table is virtually hashed, then print the list of index key
945           ** columns and their correspondig hash factors as char_value.
946           */
947           if (exists (select attribute from #sphelpattr
948                       where attribute = 'hash key factors'))
949           begin
950               /* The table is Virtually Hashed */
951               exec sp_getmessage 19586, @msg out
952               print @msg
953               print ""
954   
955               select @new_char_value = ""
956               select @num_keys = keycnt from sysindexes
957               where id = object_id(@objname)
958   
959               select @key_count = 1
960   
961               select @indid = min(indid)
962               from sysindexes
963               where id = object_id(@objname)
964                   and indid > 0
965                   and indid < 255
966   
967               set nocount on
968   
969               /*
970               ** Get the list of index key columns.
971               */
972               while (@key_count <= @num_keys)
973               begin
974                   select @thiskey =
975                       index_col(@objname, @indid, @key_count)
976   
977                   if (@thiskey is NULL)
978                   begin
979                       break
980                   end
981   
982                   if (@key_count > 1)
983                   begin
984                       select @new_char_value = @new_char_value + ", "
985                   end
986   
987                   select @new_char_value = @new_char_value + @thiskey
988   
989                   /*
990                   ** In current 'char_value', we have an array of hash
991                   ** factors of type 'double' that was written to
992                   ** 'char_value' as byte string.
993                   ** Hence to get the array of hash factors back:
994                   **
995                   ** 1. Divide 'char_value' into disjoint substrings,
996                   **    each of length 8 (sizeof double).
997                   ** 2. Convert the substring into binary type.
998                   ** 3. Convert the binary value into 'double'.
999                   **
1000                  ** Once obtained the value, convert it to character
1001                  ** type and append to @new_char_value
1002                  */
1003                  select @new_char_value = @new_char_value
1004                      + ":" +
1005                      convert(varchar(255),
1006                      convert(double precision,
1007                      convert(binary,
1008                      substring(char_value, @key_count * 8 - 7, 8))))
1009                  from #sphelpattr
1010                  where attribute = 'hash key factors'
1011  
1012                  select @key_count = @key_count + 1
1013              end
1014  
1015  
1016              /*
1017              ** Append the 'max_hash_key' to @new_char_value
1018              */
1019              select @new_char_value = @new_char_value + ", max_hash_key"
1020  
1021              select @new_char_value = @new_char_value +
1022                  "=" +
1023                  convert(varchar(255),
1024                  convert(double precision,
1025                  convert(binary,
1026                  substring(char_value, @key_count * 8 - 7, 8))))
1027              from #sphelpattr
1028              where attribute = 'hash key factors'
1029  
1030              update #sphelpattr set char_value = @new_char_value
1031              where attribute = 'hash key factors'
1032          end
1033  
1034          /*
1035          ** It's possible a cache is deleted without doing an unbind first. After
1036          ** a server reboot the binding is marked 'invalid' (int_value = 0).
1037          ** If we have such an invalid binding, don't show it in the output.
1038          */
1039          delete from #sphelpattr
1040          where class_id = 3
1041              and attribute_id = 0
1042              and int_value = 0
1043  
1044          if exists (select * from #sphelpattr)
1045          begin
1046              exec sp_autoformat @fulltabname = #sphelpattr,
1047                  @selectlist = "'attribute_class' = class, attribute, int_value,char_value, comments"
1048          end
1049          drop table #sphelpattr
1050      end
1051  
1052      /* 
1053      **  If the object is a procedure, display sysattributes information
1054      **  if there is any.
1055      */
1056  
1057      if @sysstat & 15 = 4
1058      begin
1059          if exists (select * from sysattributes
1060                  where object_type = "P"
1061                      and object = object_id(@objname))
1062          begin
1063              /* 
1064              **  The join with master..sysattributes here is to
1065              **  get the string descriptions for the class 
1066              **  (master.dbo.sysattributes c) and attribute
1067              **  (master.dbo.sysattributes a).
1068              */
1069  
1070              select attribute_class =
1071                  convert(varchar(512), c.char_value),
1072                  attribute = convert(varchar(512), a.char_value),
1073                  t.int_value,
1074                  char_value = convert(varchar(512), t.char_value),
1075                  t.comments
1076              into #sphelp6rs
1077              from sysattributes t, master.dbo.sysattributes c,
1078                  master.dbo.sysattributes a
1079              where t.object_type = "P"
1080                  and t.object = object_id(@objname)
1081                  and c.class = 0 and c.attribute = 0
1082                  and a.class = 0 and a.attribute = 1
1083                  and t.class = c.object
1084                  and t.class = a.object
1085                  and t.attribute = a.object_info1
1086  
1087              exec sp_autoformat @fulltabname = #sphelp6rs
1088              drop table #sphelp6rs
1089          end
1090      end
1091  
1092      /*
1093      **  If the object is a table, check out the indexes.
1094      */
1095      if @sysstat & 15 in (1, 3)
1096          execute dbo.sp_helpindex @objname
1097  
1098      /*
1099      **  If the object is a table or view, check out the keys.
1100      */
1101      if @sysstat & 15 in (1, 2, 3)
1102          execute dbo.sp_helpkey @objname
1103  
1104      /*
1105      **  If the object is a table, check out the slices/partitions
1106      */
1107      if @sysstat & 15 in (1, 3)
1108          execute dbo.sp_helpartition @objname
1109  
1110      /*
1111      ** If the object is a trigger, it is either enabled or disabled
1112      */
1113      if @sysstat & 15 in (0, 8)
1114      begin
1115          /*
1116          ** 1048676 <==> 0x100000 <==> insert trigger disabled
1117          ** 2097152 <==> 0x200000 <==> delete trigger disabled
1118          ** 4194304 <==> 0x400000 <==> update trigger disabled
1119          */
1120          if exists (select 1 from sysobjects trig, sysobjects tab
1121                  where trig.id = object_id(@objname)
1122                      and trig.deltrig = tab.id
1123                      and ((trig.id = tab.deltrig and tab.sysstat2 & 2097152 <> 0)
1124                          or (trig.id = tab.updtrig and tab.sysstat2 & 4194304 <> 0)
1125                          or (trig.id = tab.instrig and tab.sysstat2 & 1048576 <> 0)))
1126              exec sp_getmessage 17581, @msg out
1127          else
1128          begin
1129              /* Multiple triggers stored in sysconstraints */
1130              select @sysconstr_stat = status from sysconstraints trig
1131              where trig.constrid = object_id(@objname)
1132                  and trig.status & 3582 > 0 -- trigger reference
1133  
1134              if (@sysconstr_stat & 4096 > 0) -- trigger disabled
1135                  exec sp_getmessage 17581, @msg out
1136              else
1137                  exec sp_getmessage 17582, @msg out
1138          end
1139  
1140          print @msg
1141      end
1142  
1143      /*
1144      ** If the object is a table, display the table level LOB compression level
1145      */
1146      if @sysstat & 15 in (1, 3)
1147      begin
1148          select @tab_lob_cmplvl = lobcomp_lvl
1149          from sysobjects
1150          where id = object_id(@objname)
1151  
1152          select @msg = "Table LOB compression level " + convert(varchar(3), @tab_lob_cmplvl)
1153          print @msg
1154  
1155          if exists (select 1 from sysattributes
1156                  where object_type = "TI" and object_info1 & 4096 = 4096
1157                      and object = object_id(@objname))
1158          begin
1159              select @msg = "Table " + @objname + " has columns dropped by no datacopy method."
1160              print @msg
1161          end
1162      end
1163  
1164      /*
1165      ** Print the lock scheme information for the table objects
1166      */
1167      if @sysstat & 15 in (1, 3)
1168      begin
1169          /*
1170          ** the bits 0x2000, 0x4000 & 0x8000 represents any 
1171          ** explicit lock scheme bits that can be set, so
1172          ** get them out ( 0x2000 + 0x4000 + 0x8000 = 57344)
1173          */
1174          select @sysstat2 = (sysstat2 & 57344)
1175          from sysobjects
1176          where id = object_id(@objname)
1177          /*
1178          ** The value 0, refers that no lock scheme is 
1179          ** specified (old style tables) so they support only
1180          ** allpages locking
1181          */
1182          if (@sysstat2 in (0, 8192, 16384, 32768))
1183          begin
1184              if (@sysstat2 = 8192 or @sysstat2 = 0)
1185              begin
1186                  /* 17576, "Lock scheme is Allpages" */
1187                  exec sp_getmessage 17576, @msg out
1188                  print @msg
1189                  /* 18571, "The attribute '%1!' is */
1190                  /* not applicable to tables with  */
1191                  /* allpages lock scheme."         */
1192                  exec sp_getmessage 18571, @msg out
1193                  print @msg, 'exp_row_size'
1194                  /* 18571, "The attribute '%1!' is */
1195                  /* not applicable to tables with  */
1196                  /* allpages lock scheme."         */
1197                  exec sp_getmessage 18571, @msg out
1198                  print @msg, 'concurrency_opt_threshold'
1199              end
1200  
1201              if (@sysstat2 = 16384)
1202              begin
1203                  /* 17577, "Lock scheme is Datapages" */
1204                  exec sp_getmessage 17577, @msg out
1205                  print @msg
1206  
1207                  /* 18983, "The '%1!' attribute is not applicable 
1208                  ** to tables with datarow or datapage lock schemes.
1209                  */
1210                  exec sp_getmessage 18983, @msg out
1211                  print @msg, 'ascinserts'
1212              end
1213  
1214              if (@sysstat2 = 32768)
1215              begin
1216                  /* 17578, "Lock scheme is Datarows" */
1217                  exec sp_getmessage 17578, @msg out
1218                  print @msg
1219  
1220                  /* 18983, "The '%1!' attribute is not applicable 
1221                  ** to tables with datarow or datapage lock schemes.
1222                  */
1223                  exec sp_getmessage 18983, @msg out
1224                  print @msg, 'ascinserts'
1225              end
1226  
1227              /* Server defined value for ascinserts 
1228              ** if ascinserts is set, then master..sysindexes.status2=64 
1229              */
1230              select @opt_ind2_ascinserts = 64
1231  
1232              print " "
1233              select exp_rowsize "exp_row_size",
1234                  res_page_gap "reservepagegap",
1235                  fill_factor "fillfactor",
1236                  maxrowsperpage "max_rows_per_page",
1237                  isnull(identitygap, 0) "identity_gap",
1238                  (case when ((@opt_ind2_ascinserts & status2) > 0)
1239                      then 1
1240                      else 0
1241                  end
1242                  ) "ascinserts"
1243              from sysindexes
1244              where id = object_id(@objname)
1245                  and indid <= 1
1246  
1247              /* Server defined constant for optimistic index lock */
1248              select @opt_ind_lock = 268435456
1249  
1250              /* Server defined constant for cached dol index root page */
1251              select @tab_cached_ind = 64
1252  
1253              /* Server defined constant for dealloc first txtpg */
1254              select @db_dealloc_ftp = hextoint('0x80000000')
1255              select @tab_dealloc_ftp = hextoint("0x020000000")
1256              select @tab_keep_ftp = hextoint('0x80000000')
1257  
1258              /* Get db level status */
1259              select @db_stat4 = status4 from master.dbo.sysdatabases
1260              where dbid = db_id()
1261  
1262              select @opt_ind_status = (sysstat2 & @opt_ind_lock),
1263                  @opt_text_dealloc = (sysstat2 & (@tab_dealloc_ftp | @tab_keep_ftp)),
1264                  @tab_cached_ind = (isnull(sysstat4, 0) & @tab_cached_ind)
1265              from sysobjects where id = object_id(@objname)
1266  
1267              if (@opt_ind_status = 0)
1268                  select @opt_ind_value = 0
1269              else
1270                  select @opt_ind_value = 1
1271  
1272              if (@tab_cached_ind = 0)
1273                  select @cached_ind_val = 0
1274              else
1275                  select @cached_ind_val = 1
1276  
1277              if ((@opt_text_dealloc = @tab_dealloc_ftp) or
1278                      ((@opt_text_dealloc = 0) and (@db_stat4 & @db_dealloc_ftp != 0)))
1279                  select @opt_text_value = 1
1280              else if (@opt_text_dealloc = @tab_keep_ftp)
1281                  select @opt_text_value = 2
1282              else
1283                  select @opt_text_value = 0
1284  
1285              /*
1286              ** Currently, the following information will be same
1287              ** for all partitions, only need to print once for
1288              ** one of the partitions
1289              */
1290              select distinct
1291                  conopt_thld "concurrency_opt_threshold",
1292                  @opt_ind_value "optimistic_index_lock",
1293                  @opt_text_value "dealloc_first_txtpg",
1294                  @cached_ind_val "cached_index_root_page"
1295              from systabstats
1296              where id = object_id(@objname)
1297                  and indid <= 1
1298  
1299              return (0)
1300          end
1301          else
1302          begin
1303              /* 17579, "Lock scheme Unknown or Corrupted" */
1304              exec sp_getmessage 17579, @msg out
1305              print @msg
1306              return (1)
1307          end
1308      end
1309  
1310      /* 
1311      **  If the object is computed column, display 
1312      **  computed column information.
1313      **  We just simply follow the way sp_helpcomputedcolumn works.
1314      */
1315      if (@sysstat & 15) = 13
1316      begin
1317          declare @count int, @total int, @row_id int, @config_parm int, @mode int, @tab_name varchar(767)
1318  
1319          select @tab_name = object_name(id), @mode = status3 & 1
1320          from syscolumns
1321          where computedcol = object_id(@objname)
1322  
1323          /*
1324          ** Create temporary table to stored computed column info 
1325          */
1326          create table #helpcpc(colname varchar(255), computedcol int,
1327              property varchar(15) null, row_id numeric identity)
1328          /* 
1329          ** Get info on computed columns
1330          */
1331          if @mode != 1
1332          begin
1333              insert into #helpcpc(colname, computedcol, property)
1334              select name,
1335                  computedcol,
1336                  case when (status2 & 32 = 32) then "materialized"
1337                      else "virtual" end
1338              from syscolumns where
1339                  computedcol = object_id(@objname) and
1340                  status3 & 1 != 1
1341              order by colid
1342          end
1343          /*
1344          ** Get Info on functional index keys
1345          */
1346          else
1347          begin
1348              insert into #helpcpc(colname, computedcol)
1349              select name, computedcol from syscolumns where
1350                  computedcol = object_id(@objname) and
1351                  status3 & 1 = 1
1352              order by colid
1353          end
1354  
1355          /*
1356          ** Display the header
1357          */
1358          if @mode != 1
1359          begin
1360              exec sp_getmessage 19456, @msg output
1361          end
1362          else
1363          begin
1364              exec sp_getmessage 19457, @msg output
1365          end
1366          print ""
1367          print @msg, @tab_name
1368          print ""
1369  
1370          /*
1371          ** If the configuration parameter 'allow select on syscomments.text' 
1372          ** is set to 0, then the user can access the text ONLY in the 
1373          ** following cases
1374          ** 
1375          **	1. if the user has sa_role
1376          **	2. if the object is owned by the user
1377          **
1378          */
1379          select @config_parm = value
1380          from master.dbo.syscurconfigs
1381          where config = 258
1382  
1383          if @config_parm = 0 and user_id() != 1
1384          begin
1385              /*
1386              ** The object needs to be owned by the user
1387              */
1388              if not exists (select name from sysobjects
1389                      where uid = user_id()
1390                          and id = object_id(@objname))
1391              begin
1392                  /* 
1393                  ** Inform the user the text cannot be displayed and 
1394                  ** print the rest info before return
1395                  */
1396                  if @mode != 1
1397                  begin
1398                      exec sp_getmessage 19334, @msg output
1399                      print @msg
1400                      exec sp_autoformat #helpcpc, "'Column_Name' = colname,
1401  					Property = property"
1402                  end
1403                  else
1404                  begin
1405                      exec sp_getmessage 19335, @msg output
1406                      print @msg
1407                      exec sp_autoformat #helpcpc,
1408                          "'Internal_Index_Key_Name' = colname"
1409                  end
1410  
1411                  drop table #helpcpc
1412                  return (0)
1413              end
1414          end
1415  
1416          /*
1417          ** Now display the text
1418          */
1419          create table #helptxt(text varchar(255), row_id numeric(10) identity)
1420          create table #helpname(colname varchar(255), property varchar(15) null)
1421  
1422          select @count = 1
1423          select @total = max(row_id) + 1 from #helpcpc
1424          while @count < @total
1425          begin
1426              insert into #helpname(colname, property)
1427              select colname, property from #helpcpc where row_id = @count
1428  
1429              if @mode != 1
1430              begin
1431                  exec sp_autoformat #helpname, "'Column_Name' = colname, 
1432  					Property = property"
1433              end
1434              else
1435              begin
1436                  exec sp_autoformat #helpname,
1437                      "'Internal_Index_Key_Name' = colname"
1438              end
1439  
1440              /*
1441              ** See if the object is hidden (SYSCOM_TEXT_HIDDEN will be set)
1442              */
1443              if exists (select 1 from syscomments m, #helpcpc h where
1444                          (m.status & 1 = 1) and
1445                          m.id = h.computedcol and
1446                          h.row_id = @count)
1447              begin
1448                  exec sp_getmessage 19337, @msg output
1449                  print @msg
1450                  print ""
1451                  delete #helpname
1452                  select @count = @count + 1
1453                  continue
1454              end
1455  
1456              insert #helptxt(text) select text from syscomments, #helpcpc
1457              where row_id = @count and id = computedcol order by colid2, colid
1458  
1459              print ""
1460              if @mode != 1
1461              begin
1462                  exec sp_autoformat #helptxt, "Text = text"
1463              end
1464              else
1465              begin
1466                  select @row_id = min(row_id) from #helptxt
1467                  update #helptxt set text = right (text, char_length(text) - 4)
1468                  where row_id = @row_id
1469  
1470                  select @row_id = max(row_id) from #helptxt
1471                  update #helptxt set text = left (text, char_length(text) - 13)
1472                  where row_id = @row_id
1473                  exec sp_autoformat #helptxt, "Expression = text"
1474              end
1475              print ""
1476  
1477              select @count = @count + 1
1478              delete #helpname
1479              delete #helptxt
1480          end
1481  
1482          drop table #helpcpc, #helpname, #helptxt
1483      end
1484  
1485      return (0)
1486  
1487  


exec sp_procxmode 'sp_help', 'AnyMode'
go

Grant Execute on sp_help to public
go
RESULT SETS
sp_help_rset_002
sp_help_rset_001

DEFECTS
 QJWI 5 Join or Sarg Without Index 176
 QJWI 5 Join or Sarg Without Index 190
 QJWI 5 Join or Sarg Without Index 277
 QJWI 5 Join or Sarg Without Index 704
 QJWI 5 Join or Sarg Without Index 705
 QJWI 5 Join or Sarg Without Index 1321
 QJWI 5 Join or Sarg Without Index 1339
 QJWI 5 Join or Sarg Without Index 1350
 MEST 4 Empty String will be replaced by Single Space 185
 MEST 4 Empty String will be replaced by Single Space 187
 MEST 4 Empty String will be replaced by Single Space 196
 MEST 4 Empty String will be replaced by Single Space 200
 MEST 4 Empty String will be replaced by Single Space 418
 MEST 4 Empty String will be replaced by Single Space 445
 MEST 4 Empty String will be replaced by Single Space 473
 MEST 4 Empty String will be replaced by Single Space 479
 MEST 4 Empty String will be replaced by Single Space 566
 MEST 4 Empty String will be replaced by Single Space 824
 MEST 4 Empty String will be replaced by Single Space 850
 MEST 4 Empty String will be replaced by Single Space 856
 MEST 4 Empty String will be replaced by Single Space 880
 MEST 4 Empty String will be replaced by Single Space 886
 MEST 4 Empty String will be replaced by Single Space 895
 MEST 4 Empty String will be replaced by Single Space 953
 MEST 4 Empty String will be replaced by Single Space 955
 MEST 4 Empty String will be replaced by Single Space 1366
 MEST 4 Empty String will be replaced by Single Space 1368
 MEST 4 Empty String will be replaced by Single Space 1450
 MEST 4 Empty String will be replaced by Single Space 1459
 MEST 4 Empty String will be replaced by Single Space 1475
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MINU 4 Unique Index with nullable columns master..sysmessages master..sysmessages
 MINU 4 Unique Index with nullable columns sybsystemprocs..sysattributes sybsystemprocs..sysattributes
 MINU 4 Unique Index with nullable columns sybsystemprocs..sysjars sybsystemprocs..sysjars
 MINU 4 Unique Index with nullable columns sybsystemprocs..sysxtypes sybsystemprocs..sysxtypes
 MTYP 4 Assignment type mismatch @sysopt_name: varchar(100) = varchar(255) 418
 MTYP 4 Assignment type mismatch @sysopt_name: varchar(100) = varchar(255) 448
 MTYP 4 Assignment type mismatch @sysopt_name: varchar(100) = varchar(255) 494
 MTYP 4 Assignment type mismatch @sysopt_name: varchar(100) = varchar(255) 540
 MTYP 4 Assignment type mismatch @OS_file: varchar(255) = varchar(768) 872
 MTYP 4 Assignment type mismatch class: varchar(255) = varchar(768) 928
 MTYP 4 Assignment type mismatch attribute: varchar(255) = varchar(768) 930
 MTYP 4 Assignment type mismatch char_value: varchar(255) = varchar(768) 932
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 163
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 180
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 191
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 197
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 281
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 593
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 808
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 1046
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 1087
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 1400
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 1407
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 1431
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 1436
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 1462
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 1473
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_info2, object_info1}
Uncovered: [object_type, object, object_info3, object_cinfo]
684
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object}
Uncovered: [object_type, object_info1, object_info2, object_info3, object_cinfo]
939
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object, object_info1}
Uncovered: [object_type, object_info2, object_info3, object_cinfo]
940
 QPUI 4 Join or Sarg with Un-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}
1060
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object}
Uncovered: [object_type, object_info1, object_info2, object_info3, object_cinfo]
1083
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object, object_info1}
Uncovered: [object_type, object_info2, object_info3, object_cinfo]
1084
 QPUI 4 Join or Sarg with Un-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, object_info1, object_type}
1156
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 106
 QTYP 4 Comparison type mismatch smallint = int 106
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 177
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 179
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 276
 QTYP 4 Comparison type mismatch smallint = int 276
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 279
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 396
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 682
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 683
 QTYP 4 Comparison type mismatch Comparison type mismatch: int vs smallint 685
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 719
 QTYP 4 Comparison type mismatch Comparison type mismatch: tinyint vs int 719
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 720
 QTYP 4 Comparison type mismatch Comparison type mismatch: tinyint vs int 720
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 873
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 937
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 938
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 939
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 940
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 941
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 964
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 965
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1040
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1041
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1081
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1082
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1083
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1084
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1085
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1245
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1260
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1297
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1381
 QTYP 4 Comparison type mismatch Comparison type mismatch: numeric(18,0) vs int 1427
 QTYP 4 Comparison type mismatch Comparison type mismatch: numeric(18,0) vs int 1446
 QTYP 4 Comparison type mismatch Comparison type mismatch: numeric(18,0) vs int 1457
 QTYP 4 Comparison type mismatch Comparison type mismatch: numeric(10,0) vs int 1468
 QTYP 4 Comparison type mismatch Comparison type mismatch: numeric(10,0) vs int 1472
 TNOI 4 Table with no index master..syscurconfigs master..syscurconfigs
 TNOU 4 Table with no unique index master..spt_values master..spt_values
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 230
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 339
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 388
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 434
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 462
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 471
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 484
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 530
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 623
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 684
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 703
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 821
 MAW1 3 Warning message on %name% sybsystemprocs..sysindexes.id: Warning message on sysindexes 844
 MAW1 3 Warning message on %name% sybsystemprocs..sysindexes.id: Warning message on sysindexes 957
 MAW1 3 Warning message on %name% sybsystemprocs..sysindexes.id: Warning message on sysindexes 963
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1121
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1122
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1123
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1124
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1125
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1150
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1176
 MAW1 3 Warning message on %name% sybsystemprocs..sysindexes.id: Warning message on sysindexes 1244
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1265
 MAW1 3 Warning message on %name% sybsystemprocs..systabstats.id: Warning message on systabstats 1296
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 1319
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 1390
 MAW1 3 Warning message on %name% sybsystemprocs..syscomments.id: Warning message on syscomments 1445
 MAW1 3 Warning message on %name% sybsystemprocs..syscomments.id: Warning message on syscomments 1457
 MBLI 3 Integer Value of Binary Literal is Platform Dependant 672
 MGTP 3 Grant to public master..spt_values  
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public master..syscurconfigs  
 MGTP 3 Grant to public master..sysdatabases  
 MGTP 3 Grant to public master..sysmessages  
 MGTP 3 Grant to public sybsystemprocs..sp_help  
 MGTP 3 Grant to public sybsystemprocs..sysattributes  
 MGTP 3 Grant to public sybsystemprocs..syscolumns  
 MGTP 3 Grant to public sybsystemprocs..syscomments  
 MGTP 3 Grant to public sybsystemprocs..sysconstraints  
 MGTP 3 Grant to public sybsystemprocs..sysindexes  
 MGTP 3 Grant to public sybsystemprocs..sysjars  
 MGTP 3 Grant to public sybsystemprocs..sysobjects  
 MGTP 3 Grant to public sybsystemprocs..systabstats  
 MGTP 3 Grant to public sybsystemprocs..systypes  
 MGTP 3 Grant to public sybsystemprocs..sysxtypes  
 MNER 3 No Error Check should check @@error after select into 127
 MNER 3 No Error Check should check return value of exec 163
 MNER 3 No Error Check should check @@error after select into 167
 MNER 3 No Error Check should check return value of exec 180
 MNER 3 No Error Check should check @@error after select into 186
 MNER 3 No Error Check should check return value of exec 191
 MNER 3 No Error Check should check return value of exec 197
 MNER 3 No Error Check should check @@error after select into 264
 MNER 3 No Error Check should check return value of exec 281
 MNER 3 No Error Check should check @@error after select into 299
 MNER 3 No Error Check should check @@error after update 429
 MNER 3 No Error Check should check @@error after update 457
 MNER 3 No Error Check should check @@error after update 512
 MNER 3 No Error Check should check @@error after update 561
 MNER 3 No Error Check should check @@error after update 586
 MNER 3 No Error Check should check return value of exec 593
 MNER 3 No Error Check should check @@error after select into 645
 MNER 3 No Error Check should check @@error after update 711
 MNER 3 No Error Check should check @@error after update 717
 MNER 3 No Error Check should check @@error after update 723
 MNER 3 No Error Check should check @@error after update 729
 MNER 3 No Error Check should check @@error after update 745
 MNER 3 No Error Check should check @@error after update 803
 MNER 3 No Error Check should check return value of exec 808
 MNER 3 No Error Check should check return value of exec 825
 MNER 3 No Error Check should check return value of exec 835
 MNER 3 No Error Check should check return value of exec 851
 MNER 3 No Error Check should check return value of exec 853
 MNER 3 No Error Check should check return value of exec 869
 MNER 3 No Error Check should check return value of exec 881
 MNER 3 No Error Check should check return value of exec 883
 MNER 3 No Error Check should check return value of exec 893
 MNER 3 No Error Check should check @@error after insert 926
 MNER 3 No Error Check should check return value of exec 951
 MNER 3 No Error Check should check @@error after update 1030
 MNER 3 No Error Check should check @@error after delete 1039
 MNER 3 No Error Check should check return value of exec 1046
 MNER 3 No Error Check should check @@error after select into 1070
 MNER 3 No Error Check should check return value of exec 1087
 MNER 3 No Error Check should check return value of exec 1096
 MNER 3 No Error Check should check return value of exec 1102
 MNER 3 No Error Check should check return value of exec 1108
 MNER 3 No Error Check should check return value of exec 1126
 MNER 3 No Error Check should check return value of exec 1135
 MNER 3 No Error Check should check return value of exec 1137
 MNER 3 No Error Check should check return value of exec 1187
 MNER 3 No Error Check should check return value of exec 1192
 MNER 3 No Error Check should check return value of exec 1197
 MNER 3 No Error Check should check return value of exec 1204
 MNER 3 No Error Check should check return value of exec 1210
 MNER 3 No Error Check should check return value of exec 1217
 MNER 3 No Error Check should check return value of exec 1223
 MNER 3 No Error Check should check return value of exec 1304
 MNER 3 No Error Check should check @@error after insert 1333
 MNER 3 No Error Check should check @@error after insert 1348
 MNER 3 No Error Check should check return value of exec 1360
 MNER 3 No Error Check should check return value of exec 1364
 MNER 3 No Error Check should check return value of exec 1398
 MNER 3 No Error Check should check return value of exec 1400
 MNER 3 No Error Check should check return value of exec 1405
 MNER 3 No Error Check should check return value of exec 1407
 MNER 3 No Error Check should check @@error after insert 1426
 MNER 3 No Error Check should check return value of exec 1431
 MNER 3 No Error Check should check return value of exec 1436
 MNER 3 No Error Check should check return value of exec 1448
 MNER 3 No Error Check should check @@error after delete 1451
 MNER 3 No Error Check should check @@error after insert 1456
 MNER 3 No Error Check should check return value of exec 1462
 MNER 3 No Error Check should check @@error after update 1467
 MNER 3 No Error Check should check @@error after update 1471
 MNER 3 No Error Check should check return value of exec 1473
 MNER 3 No Error Check should check @@error after delete 1478
 MNER 3 No Error Check should check @@error after delete 1479
 MUCO 3 Useless Code Useless Brackets 129
 MUCO 3 Useless Code Useless Brackets 130
 MUCO 3 Useless Code Useless Brackets 131
 MUCO 3 Useless Code Useless Brackets 132
 MUCO 3 Useless Code Useless Brackets 201
 MUCO 3 Useless Code Useless Brackets 221
 MUCO 3 Useless Code Useless Brackets 247
 MUCO 3 Useless Code Useless Brackets 254
 MUCO 3 Useless Code Useless Brackets 285
 MUCO 3 Useless Code Useless Brackets 313
 MUCO 3 Useless Code Useless Brackets 314
 MUCO 3 Useless Code Useless Brackets 315
 MUCO 3 Useless Code Useless Brackets 316
 MUCO 3 Useless Code Useless Brackets 319
 MUCO 3 Useless Code Useless Brackets 324
 MUCO 3 Useless Code Useless Brackets 325
 MUCO 3 Useless Code Useless Brackets 326
 MUCO 3 Useless Code Useless Brackets 393
 MUCO 3 Useless Code Useless Brackets 398
 MUCO 3 Useless Code Useless Brackets 408
 MUCO 3 Useless Code Useless Brackets 413
 MUCO 3 Useless Code Useless Brackets 422
 MUCO 3 Useless Code Useless Brackets 437
 MUCO 3 Useless Code Useless Brackets 439
 MUCO 3 Useless Code Useless Brackets 473
 MUCO 3 Useless Code Useless Brackets 492
 MUCO 3 Useless Code Useless Brackets 538
 MUCO 3 Useless Code Useless Brackets 565
 MUCO 3 Useless Code Useless Brackets 566
 MUCO 3 Useless Code Useless Brackets 570
 MUCO 3 Useless Code Useless Brackets 571
 MUCO 3 Useless Code Useless Brackets 572
 MUCO 3 Useless Code Useless Brackets 575
 MUCO 3 Useless Code Useless Brackets 576
 MUCO 3 Useless Code Useless Brackets 580
 MUCO 3 Useless Code Useless Brackets 581
 MUCO 3 Useless Code Useless Brackets 674
 MUCO 3 Useless Code Useless Brackets 678
 MUCO 3 Useless Code Useless Brackets 690
 MUCO 3 Useless Code Useless Brackets 692
 MUCO 3 Useless Code Useless Brackets 697
 MUCO 3 Useless Code Useless Brackets 861
 MUCO 3 Useless Code Useless Brackets 888
 MUCO 3 Useless Code Useless Brackets 947
 MUCO 3 Useless Code Useless Brackets 972
 MUCO 3 Useless Code Useless Brackets 977
 MUCO 3 Useless Code Useless Brackets 982
 MUCO 3 Useless Code Useless Brackets 1134
 MUCO 3 Useless Code Useless Brackets 1182
 MUCO 3 Useless Code Useless Brackets 1184
 MUCO 3 Useless Code Useless Brackets 1201
 MUCO 3 Useless Code Useless Brackets 1214
 MUCO 3 Useless Code Useless Brackets 1238
 MUCO 3 Useless Code Useless Brackets 1267
 MUCO 3 Useless Code Useless Brackets 1272
 MUCO 3 Useless Code Useless Brackets 1277
 MUCO 3 Useless Code Useless Brackets 1280
 MUCO 3 Useless Code Useless Brackets 1299
 MUCO 3 Useless Code Useless Brackets 1306
 MUCO 3 Useless Code Useless Brackets 1336
 MUCO 3 Useless Code Useless Brackets 1412
 MUCO 3 Useless Code Useless Brackets 1485
 MUIN 3 Column created using implicit nullability 908
 MUIN 3 Column created using implicit nullability 1326
 MUIN 3 Column created using implicit nullability 1419
 MUIN 3 Column created using implicit nullability 1420
 MUTI 3 Update temptable with identity - 12.5.4 Regression 1467
 MUTI 3 Update temptable with identity - 12.5.4 Regression 1471
 QAFM 3 Var Assignment from potentially many rows 418
 QAFM 3 Var Assignment from potentially many rows 424
 QAFM 3 Var Assignment from potentially many rows 448
 QAFM 3 Var Assignment from potentially many rows 452
 QAFM 3 Var Assignment from potentially many rows 494
 QAFM 3 Var Assignment from potentially many rows 507
 QAFM 3 Var Assignment from potentially many rows 540
 QAFM 3 Var Assignment from potentially many rows 872
 QAFM 3 Var Assignment from potentially many rows 956
 QAFM 3 Var Assignment from potentially many rows 1003
 QAFM 3 Var Assignment from potentially many rows 1021
 QAFM 3 Var Assignment from potentially many rows 1319
 QAFM 3 Var Assignment from potentially many rows 1379
 QCRS 3 Conditional Result Set 1233
 QCRS 3 Conditional Result Set 1290
 QCTC 3 Conditional Table Creation 127
 QCTC 3 Conditional Table Creation 167
 QCTC 3 Conditional Table Creation 186
 QCTC 3 Conditional Table Creation 264
 QCTC 3 Conditional Table Creation 645
 QCTC 3 Conditional Table Creation 908
 QCTC 3 Conditional Table Creation 1070
 QCTC 3 Conditional Table Creation 1326
 QCTC 3 Conditional Table Creation 1419
 QCTC 3 Conditional Table Creation 1420
 QGWO 3 Group by/Distinct/Union without order by 1290
 QISO 3 Set isolation level 97
 QIWC 3 Insert with not all columns specified missing 2 columns out of 4 1348
 QJWT 3 Join or Sarg Without Index on temp table 725
 QJWT 3 Join or Sarg Without Index on temp table 747
 QNAJ 3 Not using ANSI Inner Join 141
 QNAJ 3 Not using ANSI Inner Join 175
 QNAJ 3 Not using ANSI Inner Join 275
 QNAJ 3 Not using ANSI Inner Join 337
 QNAJ 3 Not using ANSI Inner Join 431
 QNAJ 3 Not using ANSI Inner Join 459
 QNAJ 3 Not using ANSI Inner Join 469
 QNAJ 3 Not using ANSI Inner Join 514
 QNAJ 3 Not using ANSI Inner Join 933
 QNAJ 3 Not using ANSI Inner Join 1077
 QNAJ 3 Not using ANSI Inner Join 1120
 QNAJ 3 Not using ANSI Inner Join 1443
 QNAJ 3 Not using ANSI Inner Join 1456
 QNAO 3 Not using ANSI Outer Join 189
 QNAO 3 Not using ANSI Outer Join 702
 QNUA 3 Should use Alias: Column uid should use alias o 128
 QNUA 3 Should use Alias: Column uid should use alias o 300
 QNUA 3 Should use Alias: Column Object_status should use alias a 430
 QNUA 3 Should use Alias: Column Object_status should use alias a 458
 QNUA 3 Should use Alias: Column Object_status should use alias a 468
 QNUA 3 Should use Alias: Column Object_status should use alias a 513
 QNUA 3 Should use Alias: Column colid should use alias c 646
 QNUA 3 Should use Alias: Column text should use alias syscomments 1456
 QNUA 3 Should use Alias: Table #helpcpc 1456
 QNUA 3 Should use Alias: Table sybsystemprocs..syscomments 1456
 QNUA 3 Should use Alias: Column computedcol should use alias #helpcpc 1457
 QNUA 3 Should use Alias: Column id should use alias syscomments 1457
 QNUA 3 Should use Alias: Column row_id should use alias #helpcpc 1457
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error, langid}
104
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error}
Uncovered: [dlevel]
153
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error}
Uncovered: [dlevel]
350
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error, langid}
426
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysobjects.ncsysobjects unique
(name, uid)
Intersection: {name}
Uncovered: [uid]
432
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error, langid}
454
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysobjects.ncsysobjects unique
(name, uid)
Intersection: {name}
Uncovered: [uid]
460
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysobjects.ncsysobjects unique
(name, uid)
Intersection: {name}
Uncovered: [uid]
470
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error, langid}
509
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysobjects.ncsysobjects unique
(name, uid)
Intersection: {name}
Uncovered: [uid]
515
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error, langid}
589
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {colid, id}
Uncovered: [number]
684
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
703
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
821
 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, attribute, object_cinfo}
873
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class}
Uncovered: [attribute, object_info1, object_info2, object_info3, object_cinfo]
939
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class, attribute}
Uncovered: [object_info1, object_info2, object_info3, object_cinfo]
940
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysindexes.csysindexes unique clustered
(id, indid)
Intersection: {id}
957
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class}
Uncovered: [attribute, object_info1, object_info2, object_info3, object_cinfo]
1083
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class, attribute}
Uncovered: [object_info1, object_info2, object_info3, object_cinfo]
1084
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: systabstats.csystabstats unique clustered
(id, indid, partitionid)
Intersection: {indid, id}
1296
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: syscomments.csyscomments unique clustered
(id, number, colid2, colid, texttype)
Intersection: {id}
Uncovered: [number, colid2, colid, texttype]
1445
 QPRI 3 Join or Sarg with Rooted Partial Index Use JOIN Candidate index: syscomments.csyscomments unique clustered
(id, number, colid2, colid, texttype)
Intersection: {id}
Uncovered: [number, colid2, colid, texttype]
1457
 QSWV 3 Sarg with variable @valstat2, Candidate Index: spt_values.spt_valuesclust clustered(number, type) F 420
 QSWV 3 Sarg with variable @valstat4, Candidate Index: spt_values.spt_valuesclust clustered(number, type) F 450
 QSWV 3 Sarg with variable @valstat3, Candidate Index: spt_values.spt_valuesclust clustered(number, type) F 496
 QSWV 3 Sarg with variable @valstat3, Candidate Index: spt_values.spt_valuesclust clustered(number, type) F 523
 QSWV 3 Sarg with variable @valstat4, Candidate Index: spt_values.spt_valuesclust clustered(number, type) F 542
 QSWV 3 Sarg with variable @valstat4, Candidate Index: spt_values.spt_valuesclust clustered(number, type) F 547
 QTLO 3 Top-Level OR 719
 QTLO 3 Top-Level OR 798
 QTLO 3 Top-Level OR 804
 VNRD 3 Variable is not read @dbname 869
 VNRD 3 Variable is not read @retcode 869
 VNRD 3 Variable is not read @site 869
 VNRD 3 Variable is not read @owner 870
 VUNU 3 Variable is not used @len1 45
 VUNU 3 Variable is not used @len2 45
 VUNU 3 Variable is not used @len3 45
 VUNU 3 Variable is not used @len4 45
 VUNU 3 Variable is not used @len5 45
 VUNU 3 Variable is not used @len6 45
 MRST 2 Result Set Marker 1233
 MRST 2 Result Set Marker 1290
 MSUB 2 Subquery Marker 103
 MSUB 2 Subquery Marker 228
 MSUB 2 Subquery Marker 254
 MSUB 2 Subquery Marker 587
 MSUB 2 Subquery Marker 725
 MSUB 2 Subquery Marker 741
 MSUB 2 Subquery Marker 747
 MSUB 2 Subquery Marker 757
 MSUB 2 Subquery Marker 767
 MSUB 2 Subquery Marker 778
 MSUB 2 Subquery Marker 788
 MSUB 2 Subquery Marker 798
 MSUB 2 Subquery Marker 821
 MSUB 2 Subquery Marker 947
 MSUB 2 Subquery Marker 1059
 MSUB 2 Subquery Marker 1120
 MSUB 2 Subquery Marker 1155
 MSUB 2 Subquery Marker 1388
 MSUB 2 Subquery Marker 1443
 MSUC 2 Correlated Subquery Marker 680
 MTR1 2 Metrics: Comments Ratio Comments: 31% 34
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 191 = 197dec - 8exi + 2 34
 MTR3 2 Metrics: Query Complexity Complexity: 792 34
 PRED_QUERY_COLLECTION 2 {m=master..sysmessages, o=sybsystemprocs..sysobjects, sv=master..spt_values, sv2=master..spt_values} 0 127
 PRED_QUERY_COLLECTION 2 {t=sybsystemprocs..systypes, t2=sybsystemprocs..systypes} 0 167
 PRED_QUERY_COLLECTION 2 {t=sybsystemprocs..systypes, t2=sybsystemprocs..systypes} 0 264
 PRED_QUERY_COLLECTION 2 {m=master..sysmessages, o=sybsystemprocs..sysobjects, sv=master..spt_values, sv2=master..spt_values} 0 299
 PRED_QUERY_COLLECTION 2 {a=sybsystemprocs..sysattributes, c=sybsystemprocs..syscolumns} 0 680
 PRED_QUERY_COLLECTION 2 {a=sybsystemprocs..sysattributes, a2=master..sysattributes, a3=master..sysattributes} 0 928
 PRED_QUERY_COLLECTION 2 {a=master..sysattributes, a2=sybsystemprocs..sysattributes, a3=master..sysattributes} 0 1070
 PRED_QUERY_COLLECTION 2 {o=sybsystemprocs..sysobjects, o2=sybsystemprocs..sysobjects} 0 1120

DATA PROPAGATION detailed
ColumnWritten To
@objnamesp_helpartition_rset_001.Avg_pages °.Max_pages °.Min_pages °.Ratio(Max/Avg) °.Ratio(Min/Avg)

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_getmessage  
   reads table sybsystemprocs..sysusermessages  
   reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
calls proc sybsystemprocs..sp_autoformat  
   calls proc sybsystemprocs..sp_autoformat  
   writes table sybsystemprocs..sp_autoformat_rset_001 
   writes table sybsystemprocs..sp_autoformat_rset_005 
   read_writes table tempdb..#colinfo_af (1) 
   reads table tempdb..systypes (1)  
   calls proc sybsystemprocs..sp_namecrack  
   writes table sybsystemprocs..sp_autoformat_rset_002 
   writes table sybsystemprocs..sp_autoformat_rset_003 
   reads table tempdb..syscolumns (1)  
   reads table master..syscolumns (1)  
   writes table sybsystemprocs..sp_autoformat_rset_004 
   reads table master..systypes (1)  
read_writes table tempdb..#helptxt (1) 
reads table master..sysdatabases (1)  
reads table sybsystemprocs..sysxtypes  
writes table tempdb..#sphelp3rs (1) 
writes table tempdb..#sphelp4rs (1) 
reads table sybsystemprocs..sysjars  
reads table sybsystemprocs..sysconstraints  
calls proc sybsystemprocs..sp_helpcomputedcolumn  
   reads table master..syscurconfigs (1)  
   calls proc sybsystemprocs..sp_autoformat  
   reads table sybsystemprocs..syscolumns  
   reads table sybsystemprocs..sysobjects  
   read_writes table tempdb..#helptxt (1) 
   writes table tempdb..#helpname (1) 
   calls proc sybsystemprocs..sp_getmessage  
   reads table sybsystemprocs..syscomments  
   read_writes table tempdb..#helpcpc (1) 
reads table master..sysattributes (1)  
read_writes table tempdb..#helptype (1) 
reads table master..syscurconfigs (1)  
read_writes table tempdb..#sphelpattr (1) 
reads table master..spt_values (1)  
read_writes table tempdb..#helpcpc (1) 
read_writes table tempdb..#sphelp5rs (1) 
writes table tempdb..#sphelp1rs (1) 
calls proc sybsystemprocs..sp_helpkey  
   calls proc sybsystemprocs..sp_getmessage  
   reads table sybsystemprocs..syskeys  
   calls proc sybsystemprocs..sp_autoformat  
   writes table tempdb..#sphelpkeys2rs (1) 
   writes table tempdb..#sphelpkeys1rs (1) 
   reads table master..spt_values (1)  
   reads table sybsystemprocs..sysobjects  
reads table sybsystemprocs..syscomments  
reads table master..sysmessages (1)  
writes table tempdb..#sphelp6rs (1) 
reads table sybsystemprocs..sysindexes  
writes table sybsystemprocs..sp_help_rset_001 
writes table tempdb..#sphelp2rs (1) 
writes table sybsystemprocs..sp_help_rset_002 
reads table sybsystemprocs..sysattributes  
reads table sybsystemprocs..systypes  
calls proc sybsystemprocs..sp_helpindex  
   reads table sybsystemprocs..syspartitions  
   writes table tempdb..#sphelpindex1rs (1) 
   writes table tempdb..#spindtab (1) 
   reads table master..spt_values (1)  
   reads table sybsystemprocs..sysattributes  
   read_writes table tempdb..#spindattr (1) 
   reads table sybsystemprocs..syssegments  
   calls proc sybsystemprocs..sp_autoformat  
   reads table master..sysattributes (1)  
   calls proc sybsystemprocs..sp_getmessage  
   reads table sybsystemprocs..sysobjects  
   writes table tempdb..#spindptn (1) 
   reads table sybsystemprocs..sysindexes  
   calls proc sybsystemprocs..sp_helpcomputedcolumn  
calls proc sybsystemprocs..sp_help_params  
   read_writes table tempdb..#helpproc (1) 
   calls proc sybsystemprocs..sp_autoformat  
   reads table master..spt_values (1)  
   reads table sybsystemprocs..sysxtypes  
   reads table sybsystemprocs..syscolumns  
   reads table master..sysmessages (1)  
   reads table sybsystemprocs..systypes  
reads table sybsystemprocs..sysobjects  
reads table sybsystemprocs..systabstats  
calls proc sybsystemprocs..sp_namecrack  
calls proc sybsystemprocs..sp_helpartition  
   writes table tempdb..#result_cond (1) 
   calls proc sybsystemprocs..sp_getmessage  
   reads table sybsystemprocs..syspartitionkeys  
   calls proc sybsystemprocs..sp_autoformat  
   reads table sybsystemprocs..syscomments  
   reads table sybsystemprocs..syssegments  
   reads table master..spt_values (1)  
   reads table sybsystemprocs..sysobjects  
   reads table sybsystemprocs..sysindexes  
   reads table sybsystemprocs..syspartitions  
   writes table tempdb..#result_body (1) 
   writes table tempdb..#result_head (1) 
   reads table sybsystemprocs..syscolumns  
   reads table master..syscurconfigs (1)  
   writes table sybsystemprocs..sp_helpartition_rset_001 
   writes table tempdb..#all_tables (1) 
   writes table tempdb..#result_all (1) 
   read_writes table tempdb..#col_names (1) 
writes table tempdb..#helpname (1) 
reads table sybsystemprocs..syscolumns