use sybsystemprocs
go

sp_dropprocedure sp_execsizes
go
sp_dropprocedure sp_length
go
sp_dropprocedure sp_size
go
sp_dropprocedure sp_sizes
go
sp_dropprocedure sp_spacebyuser
go

set quoted_identifier on
go

create procedure sp_execsizes (@PAGES  smallint) as
   set ansinull                      on
   set flushmessage                  on
   set string_rtruncation            on

   print ' '

   if (@@trancount = 0)
      begin
         set chained off

         if (@@isolation > 1)
            begin
               set transaction isolation level 1
            end
      end
   else
      begin
         print '    sp_execsizes CANNOT BE RUN FROM WITHIN A TRANSACTION.'

         print ' '

         return 1
      end

   declare @cmdstring1  varchar (255),
           @cmdstring2  varchar (255),
           @format_lks  varchar ( 11),
           @format_mrp  varchar (  6),
           @format_pgs  varchar ( 11),
           @maxrows     int,
           @namelen     tinyint,
           @procid      int,
           @procpgs     int,
           @syslocks    int

   create table #execsizes
      (id       int           not null,
       uid      smallint      not null,
       ostatus  tinyint       not null,
       pstatus  smallint      not null,
       name     varchar (40)  not null,
       crdate   char (8)      not null,
       pages    int           not null,
       textrows int           not null,
       typetext char (7)      not null)

   select @format_pgs = convert (varchar (6), @PAGES)

   select @maxrows = max (sequence)
   from sysprocedures

   select @procpgs = used_pgs (id, doampg, ioampg)
   from sysindexes
   where id = object_id ('sysprocedures')

   select @syslocks = value
   from master.dbo.syscurconfigs
   where config = 106

   if ((8 * @PAGES) > (1 + @maxrows))
      begin
         select @maxrows = 1 + (@maxrows / 8)

         select @format_mrp = ltrim (substring (convert (char (9), convert (money, @maxrows), 1), 1, 6))

         print '    THE LARGEST EXECUTEABLE OBJECT USES %1! PAGES.', @format_mrp

         print ' '
      end
   else
      begin
         if ((@@isolation > 0)  and  ((10 * @syslocks) < (12 * @procpgs)))
            begin
               select @format_lks = ltrim (substring (convert (char (14), convert (money, @syslocks), 1), 1, 11)),
                      @format_pgs = ltrim (substring (convert (char (14), convert (money, @procpgs), 1), 1, 11))

               print '    THERE ARE %1! SYSTEM LOCKS AND %2! SYSPROCEDURES PAGES.',
                     @format_lks, @format_pgs

               print ' '

               print '    TRANSACTION ISOLATION LEVEL 0 WILL BE USED.'

               print ' '

               set transaction isolation level 0
            end

         insert into #execsizes
            select distinct o.id,
                            o.uid,
                            (o.sysstat & 15),
                            (p.status & 4096),
                            o.name,
                            convert (char (8), o.crdate, 11),
                            1 + (count (p.sequence) / 8),
                            0,
                            o.type
            from sysobjects o,
                 sysprocedures p
            where o.id = p.id
            group by o.id
            having o.id               = p.id
               and count (p.sequence) > (8 * (@PAGES - 1))

         update #execsizes
         set name = substring (name  +  ' ('  +  user_name (uid)  +  ')', 1, 40)
         from #execsizes e
         where e.uid <> 1
            or 1      < (select count (distinct o.uid)
                         from sysobjects o
                         where o.name = e.name)

         select @namelen = max (char_length (name))
         from #execsizes

         update #execsizes
         set textrows = (select count (c.id)
                         from syscomments c
                         where c.id       = ps.id
                           and c.texttype = 0)
         from #execsizes ps

         update #execsizes
         set typetext = case  ostatus
                           when 2 then 'View'
                           when 4 then case  typetext
                                          when 'P'  then 'SP'
                                          when 'XP' then 'XP'
                                          else           'UNKNOWN'
                                       end
                           when 6 then 'Default'
                           when 7 then case  pstatus
                                          when 4096  then 'Check'
                                          else            'Rule'
                                       end
                           when 8 then 'Trigger'
                           else        'UNKNOWN'
                        end

         select @cmdstring1 = 'select CREATED = crdate,'
                              +  'TYPE = typetext,'
                              +  '''OBJECT'' = substring (name, 1,'
                              +  convert (varchar (2), @namelen)
                              +  '),'
                              +  'PAGES = substring (convert (char (12), convert (money, pages), 1), 1, 9),'
                              +  '''TEXT ROWS'' = substring (convert (char (12), convert (money, textrows), 1), 1, 9)'

         select @cmdstring2 = ' from #execsizes'
                              +  ' order by pages desc, textrows desc, name asc'

         execute  (@cmdstring1  +  @cmdstring2)
      end
go
sp_addcomment sp_execsizes, 'Lists size data for executeables with #exec rows > SIZE'
go
sp_procxmode sp_execsizes, anymode
go

create procedure sp_length (@TABLE  varchar (30))  as
   set ansinull                      on
   set close on endtran              on
   set flushmessage                  on
   set nocount                       on
   set string_rtruncation            on

   if (@@trancount = 0)
      begin
         set chained off

         if (@@isolation > 0)
            begin
               set transaction isolation level 0
            end
      end
   else
      begin
         print '    sp_length CANNOT BE RUN FROM WITHIN A TRANSACTION.'

         print ' '

         return 1
      end

   print ' '

   declare @cmdstring1  varchar (255),
           @cmdstring2  varchar (255),
           @errorchar   varchar (  4),
           @colname     varchar ( 30),
           @collen      tinyint,
           @likestring  varchar ( 30),
           @namelen     tinyint,
           @nulltype    tinyint,
           @objtype     tinyint,
           @tableid     int,
           @tabname     varchar ( 30),
           @tabstatcnt  varchar ( 11),
           @uid         smallint,
           @usertype    varchar ( 32),
           @utlen       tinyint

   declare length_cursor cursor for
      select c.name, t.name, c.length, convert (tinyint, convert (bit, (c.status & 8)))
      from syscolumns c,
           systypes t
      where c.id       = @tableid
        and t.usertype = c.usertype
        and ((c.usertype in (2, 4, 18, 25))  or
             ((c.usertype > 99)  and  (c.type in (37, 39))))
      order by c.colid
   for read only

   create table #length
      (name       varchar (30)  not null,
       usertype   varchar (30)  not null,
       avglen     char ( 7)     null,
       maxlen     tinyint       null,
       definelen  tinyint       null)

   select @tableid = object_id (@TABLE)

   select @objtype = (sysstat & 15),
          @uid     = uid
   from sysobjects
   where id = @tableid

   if (@objtype > 3)
      begin
         print '    OBJECT %1! IS NOT A TABLE OR VIEW.', @TABLE
      end
   else if (@tableid IS NULL)
      begin
         print '    TABLE/VIEW %1! DOES NOT EXIST.', @TABLE

         print ' '

         execute  sp_like_string  @INPUT_STRING=@TABLE,
                                  @LIKE_STRING=@likestring  output

         if (exists (select *
                     from sysobjects
                     where name          like @likestring
                       and uid              = user_id ()
                       and (sysstat & 15)  in (1, 2, 3)))
            begin
               print '    THERE ARE TABLES/VIEWS LIKE %1!.', @likestring

               print ' '

               print '    CONSIDER THE FOLLOWING AS ARGUMENTS.'

               print ' '

               select 'TABLE/VIEW' = name
               from sysobjects
               where name          like @likestring
                 and uid              = user_id ()
                 and (sysstat & 15)  <= 4
               order by name
            end
      end
   else if ((charindex ('sa_role', show_role ()) = 0)  and
            (user_id () <> @uid)                       and
            (not exists (select *
                         from sysprotects p
                         where id           = @tableid
                           and action       = 193
                           and protecttype in (0, 1)
                           and uid          = user_id ()
                           and ((columns IS NULL)  or  (columns = 0)))))
      begin
         print '    YOU DO NOT HAVE select PERMISSIONS ON %1!.', @TABLE
      end
   else
      begin
         open length_cursor

         fetch length_cursor into @colname, @usertype, @collen, @nulltype

         if (@@sqlstatus = 2)
            begin
               print '    TABLE %1! DOES NOT HAVE ANY VARIABLE LENGTH COLUMNS.', @TABLE

               print ' '
            end
         else
            begin
               select @tabstatcnt = ltrim (substring (convert (char (14), convert (money, rowcnt), 1), 1, 11))
               from systabstats
               where id    = @tableid
                 and indid < 2

               if (@tabstatcnt IS NULL)
                  begin
                     print '    COLUMN LENGTHS ARE FOR VIEW %1!.', @TABLE
                  end
               else
                  begin
                     print '    COLUMN LENGTHS ARE FOR TABLE %1! (%2! ROWS).',
                           @TABLE, @tabstatcnt
                  end

               print ' '

               select @tabname = @TABLE

               select @tabname = '"'  +  @tabname  +  '"'
               where valid_name (@tabname) = 0

               while (@@sqlstatus = 0)
                  begin
                     if (@nulltype = 1)
                        begin
                           select @usertype = @usertype  +  ' *'
                        end

                     select @cmdstring1 = 'insert into #length select '''
                                          +  rtrim (@colname)
                                          +  ''', '''
                                          +  @usertype
                                          +  ''', '

                     select @cmdstring2 = 'substring (convert (char (8), convert (money, round (avg (convert (double precision, char_length (isnull ("'
                                          +  @colname
                                          +  '", '' '')))), 1), 1)), 1, 7), max (char_length (isnull ("'
                                          +  @colname
                                          +  '", '' ''))), '
                                          +  convert (varchar (3), @collen)
                                          +  ' from '

                     if (valid_name (@colname) <> 0)
                        begin
                           while (charindex ('"', @cmdstring1) > 0)
                              begin
                                 select @cmdstring1 = stuff (@cmdstring1, charindex ('"', @cmdstring1), 1, NULL)
                              end

                           while (charindex ('"', @cmdstring2) > 0)
                              begin
                                 select @cmdstring2 = stuff (@cmdstring2, charindex ('"', @cmdstring2), 1, NULL)
                              end
                        end

                     execute  (@cmdstring1  +  @cmdstring2  +  @tabname)

                     fetch length_cursor into @colname, @usertype, @collen, @nulltype
                  end

               if (@@sqlstatus = 2)
                  begin
                     update #length
                     set avglen    = coalesce (avglen, '    0.0'),
                         maxlen    = coalesce (maxlen, 0),
                         definelen = coalesce (definelen, 0)

                     select @namelen = max (char_length (name)),
                            @utlen   = max (char_length (usertype))
                     from #length

                     select @cmdstring1 = 'select COLUMN = substring (name, 1,'
                                          +  convert (varchar (2), @namelen)
                                          +  '),'
                                          +  ' USERTYPE = substring (usertype, 1,'
                                          +  convert (varchar (2), @utlen)
                                          +  '),'
                                          +  ' AVERAGE = avglen,'
                                          +  ' MAXIMUM = maxlen,'
                                          +  ' DEFINED = definelen'
                                          +  ' from #length'

                     execute  (@cmdstring1)
                  end
               else
                  begin
                     select @errorchar = convert (varchar (4), @@sqlstatus)

                     print '  CURSOR ERROR.  STATUS = %1!.', @errorchar

                     return 1
                  end
            end

         close length_cursor

         deallocate cursor length_cursor
      end

   print ' '
go
sp_addcomment sp_length, 'Displays length data for variable length columns in TABLE/VIEW'
go

create procedure sp_size (@OBJECT varchar (63)) as
   set ansinull                      on
   set nocount                       on
   set string_rtruncation            on

   print ' '

   if (@@trancount = 0)
      begin
         set chained off

         if (@@isolation > 1)
            begin
               set transaction isolation level 1
            end
      end
   else
      begin
         print '    sp_size CANNOT BE RUN FROM WITHIN A TRANSACTION.'

         print ' '

         return 1
      end

   declare @cmnt0rows   char ( 19),
           @i           tinyint,
           @j           tinyint,
           @likestring  varchar ( 63),
           @objectid    int,
           @pages       char ( 12),
           @pstatus     smallint,
           @sysstat     tinyint,
           @type        char (  2),
           @typetext    char ( 18)

   select @i        = 1,
          @objectid = id,
          @sysstat  = (sysstat & 15),
          @type     = type
   from sysobjects
   where id = object_id (@OBJECT)
   having id = object_id (@OBJECT)

   select @likestring = @OBJECT

   select @j = charindex ('_', @likestring)

   while (@j <> @i - 1)
      begin
         select @likestring = stuff (@likestring, @j, 1, '[_]')

         select @i = @j + 3

         select @j = @i - 1 + charindex ('_', substring (@likestring, @i, 255))
      end

   select @likestring = @likestring + '%'

   if (@sysstat in (1, 3))
      begin
         select OWNER            = substring (isnull (user_name (o.uid), '?'), 1, 16),
                'RESERVED PAGES' = substring (convert (char (17),
                                                       convert (money,
                                                                reserved_pgs (i.id, i.doampg)),
                                                       1),
                                              1,
                                              14),
                'DATA PAGES'     = substring (convert (char (13),
                                                       convert (money,
                                                                data_pgs (i.id, i.doampg)),
                                                       1),
                                              1,
                                              10),
                'TEXT PAGES'     = substring (isnull (convert (char (13),
                                                               convert (money,
                                                                        data_pgs (t.id, t.ioampg)),
                                                               1),
                                                      '         -   '),
                                              1,
                                              10),
                'APP ROWS'       = substring (convert (char (16),
                                                       convert (money,
                                                                rowcnt (i.doampg)),
                                                       1),
                                              1,
                                              13),
                'MAX LEN'        = convert (smallint, i.maxlen)
         from sysobjects o  inner join  sysindexes i
           on i.id    = o.id
          and i.indid < 2
         left join  sysindexes t
           on t.id    = o.id
          and t.indid = 255
         where o.id = @objectid

         if (exists (select *
                     from sysindexes
                     where id    = @objectid
                       and indid > 0))
            begin
               print ' '

               select 'INDEX ID'       = i.indid,
                      'RESERVED PAGES' = substring (convert (char (17),
                                                             convert (money,
                                                                      reserved_pgs (i.id, i.ioampg)),
                                                             1),
                                                    1,
                                                    14),
                      'INDEX PAGES'    = substring (convert (char (14),
                                                             convert (money,
                                                                      data_pgs (i.id, i.ioampg)),
                                                             1),
                                                    1,
                                                    11),
                      'INDEX/DATA %'   = convert (smallint,
                                                  (100 * data_pgs (i.id, i.ioampg)) / data_pgs (d.id, d.doampg))
               from sysindexes d,
                    sysindexes i

               where d.id    = @objectid
                 and d.indid < 2
                 and i.id    = @objectid
                 and i.indid > 0
                 and i.indid < 255
               order by i.indid
            end
      end
   else if (@sysstat in (2, 4, 6, 7, 8))
      begin
         select @pages   = convert (char (12), convert (money, 1 + (count (*) / 8)), 1),
                @pstatus = (status & 4096)
         from sysprocedures
         where id = @objectid
         having id = @objectid

         select @typetext = case  @sysstat
                               when 2 then 'View'
                               when 4 then case  @type
                                              when 'P'  then 'Stored Procedure'
                                              when 'XP' then 'Extended Procedure'
                                              else           'UNKNOWN'
                                           end
                               when 6 then 'Default'
                               when 7 then case  @pstatus
                                              when 4096  then 'Check'
                                              else            'Rule'
                                           end
                               when 8 then 'Trigger'
                               else        'UNKNOWN'
                            end

         select @cmnt0rows = substring (convert (char (13), convert (money, count (*)), 1), 1, 10)
         from syscomments
         where id       = @objectid
           and texttype = 0

         select TYPE         = @typetext,
                'EXEC PAGES' = substring (convert (char (13), convert (money, @pages), 1), 1, 10),
                'TEXT ROWS'  = substring (@cmnt0rows, 1, 10)
      end
   else if (exists (select *
                    from sysobjects
                    where name           like @likestring
                      and (sysstat & 15)   in (1, 2, 3, 4, 6, 7, 8)))
      begin
         print '    THERE IS NO OBJECT %1! BUT THERE ARE OBJECTS LIKE %2!.',
               @OBJECT, @likestring

         print ' '

         print '    USE sp_size WITH ONE OF THESE.'

         print ' '

         select OWNER          = substring (user_name (o.uid), 1, 26),
                OBJECT         = substring (o.name, 1, 26),
                TYPE           = substring (vO.name, 1, 23)
         from sysobjects o,
              sybsystemprocs.dbo.usptvalues vO
         where o.name    like @likestring
           and vO.number    = convert (int, o.sysstat & 15)
           and vO.type      = 'O'
           and vO.number   in (1, 2, 3, 4, 7, 8)
         order by o.name, user_name (o.uid)
      end
   else
      begin
         print '    OBJECT %1! DOES NOT EXIST OR HAS NO SIZE.', @OBJECT

         print ' '

         return 1
      end
go
sp_addcomment sp_size, 'Displays size data for an OBJECT'
go
sp_procxmode sp_size, anymode
go

create procedure sp_sizes (@PAGES int) as
   set ansinull                      on
   set string_rtruncation            on

   print ' '

   if (@@trancount = 0)
      begin
         set chained off

         if (@@isolation > 1)
            begin
               set transaction isolation level 1
            end
      end
   else
      begin
         print '    sp_sizes CANNOT BE RUN FROM WITHIN A TRANSACTION.'

         print ' '

         return 1
      end

   declare @format_mp  varchar (15),
           @maxpages   int

   select @maxpages = max (sum (data_pgs (i.id, i.doampg))  +  sum (data_pgs (i.id, i.ioampg)))
   from sysindexes i
   group by i.id

   if (@PAGES > @maxpages)
      begin
         select @format_mp = ltrim (substring (convert (char (18), convert (money, @maxpages), 1), 1, 15))

         print '    THE LARGEST TABLE HAS %1! PAGES', @format_mp

         print ' '
      end
   else
      begin
         create table #sizes
            (id        int           not null,
             name      varchar (30)  not null,
             uid       smallint      not null,
             totpgs    int           not null,
             datapgs   int           not null,
             indexpgs  int           null,
             textpgs   int           null,
             arows     int           null,
             typetext  char ( 1)     not null)

         insert into #sizes
            select distinct o.id, o.name, o.uid, 0, 0, 0, 0, 0, substring (o.type, 1, 1)
            from sysobjects o,
                 sysindexes i
            where (o.sysstat & 15) in (1, 3)
              and i.id              = o.id
            group by o.id
            having (o.sysstat & 15) in (1, 3)
               and i.id              = o.id
               and @PAGES            < sum (data_pgs (i.id, i.doampg))
                                       +  sum (data_pgs (i.id, i.ioampg))

         update #sizes
         set name = substring (s.name + ' (' + user_name (s.uid) + ')', 1, 30)
         from #sizes s
         where s.uid <> 1
            or 1      < (select count (o.uid)
                         from sysobjects o
                         where o.name            = s.name
                           and (o.sysstat & 15) in (1, 3))

         update #sizes
         set datapgs  = (select data_pgs (i.id, i.doampg)
                         from sysindexes i
                         where i.id    = s.id
                           and i.indid < 2),
             indexpgs = (select sum (data_pgs (i.id, i.ioampg))
                         from sysindexes i
                         where i.id    = s.id
                           and i.indid > 0
                           and i.indid < 255),
             textpgs  = (select data_pgs (i.id, i.ioampg)
                         from sysindexes i
                         where i.id    = s.id
                           and i.indid = 255),
             arows    = (select t.rowcnt
                         from systabstats t
                         where t.id    = s.id
                           and t.indid < 2)
         from #sizes s

         update #sizes
         set totpgs = datapgs  +  coalesce (indexpgs, 0)  +  coalesce (textpgs, 0)

         update #sizes
         set arows = NULL
         where id = 8

         select 'TABLE'       = substring (name, 1, 24),
                'DATA PAGES'  = substring (convert (char (14),
                                                    convert (money,
                                                             datapgs),
                                                    1),
                                           1,
                                           11),
                'INDEX PAGES' = substring (coalesce (convert (char (14),
                                                              convert (money,
                                                                       indexpgs),
                                                              1),
                                                     '          ----'),
                                           1,
                                           11),
                'TEXT PAGES'  = substring (coalesce (convert (char (14),
                                                              convert (money,
                                                                       textpgs),
                                                              1),
                                                     '          ----'),
                                           1,
                                           11),
                'APP ROWS'    = substring (coalesce (convert (char (14),
                                                              convert (money,
                                                                       arows),
                                                              1),
                                                     '          ----'),
                                           1,
                                           11),
                TYPE          = '   '  +  typetext
         from #sizes
         order by totpgs desc, name
      end
go
sp_addcomment sp_sizes, 'Lists size data for tables with #pages > SIZE'
go
sp_procxmode sp_sizes, anymode
go

create procedure sp_spacebyuser as
   set ansinull                      on
   set string_rtruncation            on

   print ' '

   if (@@trancount = 0)
      begin
         set chained off

         if (@@isolation > 1)
            begin
               set transaction isolation level 1
            end
      end
   else
      begin
         print '    sp_spacebyuuser CANNOT BE RUN FROM WITHIN A TRANSACTION.'

         print ' '

         return 1
      end

   create table #spacebyuser
      (uid     smallint      not null,
       owner   varchar (30)  not null,
       adata   int           not null,
       udata   int           not null,
       aindex  int           not null,
       uindex  int           not null,
       txt     int           not null)

   insert into #spacebyuser
      select distinct o.uid,
                      user_name (o.uid),
                      sum (reserved_pgs (i.id, i.doampg)),
                      sum (data_pgs (i.id, i.doampg)),
                      0,
                      0,
                      0
      from sysindexes i,
           sysobjects o
      where o.id    > 99
        and i.id    = o.id
        and i.indid < 2
      group by o.uid
      having o.id    > 99
         and i.id    = o.id
         and i.indid < 2

   insert into #spacebyuser
      select -1,
             '(system tables)',
             sum (reserved_pgs (id, doampg)),
             sum (data_pgs (id, doampg)),
             0,
             0,
             0
      from sysindexes
      where id     < 100
        and id    <> 8
        and indid  < 2

   update #spacebyuser
   set aindex = (select sum (reserved_pgs (id, ioampg))
                 from sysindexes
                 where id     < 100
                   and id    <> 8
                   and indid  > 0
                   and indid  < 254),
       uindex = (select sum (data_pgs (id, ioampg))
                 from sysindexes
                 where id     < 100
                   and id    <> 8
                   and indid  > 0
                   and indid  < 254),
       txt    = (select sum (data_pgs (id, ioampg))
                 from sysindexes
                 where id     < 100
                   and id    <> 8
                   and indid  > 253)
   where uid = -1

   update #spacebyuser
   set aindex = (select isnull (sum (reserved_pgs (i.id, i.ioampg)), 0)
                 from sysindexes i,
                      sysobjects o
                 where o.uid   = s.uid
                   and o.id    = i.id
                   and i.id    > 99
                   and i.indid > 0
                   and i.indid < 254),
       uindex = (select isnull (sum (data_pgs (i.id, i.ioampg)), 0)
                 from sysindexes i,
                      sysobjects o
                 where o.uid   = s.uid
                   and o.id    = i.id
                   and i.id    > 99
                   and i.indid > 0
                   and i.indid < 254),
       txt    = (select isnull (sum (data_pgs (i.id, i.ioampg)), 0)
                 from sysindexes i,
                      sysobjects o
                 where o.uid    = s.uid
                   and o.id     = i.id
                   and i.id     > 99
                   and i.indid  > 253)
     from #spacebyuser s
     where s.uid > -1

   if (exists (select *
               from master.dbo.sysusages
               where dbid   = db_id ()
                 and segmap = 4))
      begin
         insert into #spacebyuser
            select distinct -2,
                            '(transaction log)',
                            sum (u.size),
                            data_pgs (8, i.doampg),
                            0,
                            0,
                            0
            from sysindexes i,
                 master.dbo.sysusages u
            where i.id     = 8
              and u.dbid   = db_id ()
              and u.segmap = 4
            group by u.dbid
            having i.id     = 8
               and u.dbid   = db_id ()
               and u.segmap = 4
      end
   else
      begin
         print '    SPACE USAGE FOR THE NON-DEDICATED TRANSACTION LOG IS UNAVAILABLE.'

         print ' '
      end

   select 'USER'         = substring (owner, 1, 15),
          'ALLOC DPAGES' = substring (convert (char (15), convert (money, adata), 1), 1, 12),
          'USED DPAGES'  = substring (convert (char (14), convert (money, udata), 1), 1, 11),
          'ALLOC IPAGES' = substring (convert (char (15), convert (money, aindex), 1), 1, 12),
          'USED IPAGES'  = substring (convert (char (14), convert (money, uindex), 1), 1, 11),
          'TEXT PAGES'   = substring (convert (char (14), convert (money, txt), 1), 1, 11)
   from #spacebyuser
   order by owner
go
sp_addcomment sp_spacebyuser, 'Lists aggregate table space by user'
go
sp_procxmode sp_spacebyuser, anymode
go

dump transaction sybsystemprocs with truncate_only
go
