Tuesday, March 14, 2017

Restrict user by ip address in sybase

SQL
Maybe usefull to use to restrict users by ip address
create group restrictedusergroup
go
create proc restrictuser as
declare @ip char(15)
select @ip = ipaddr from master..sysprocesses where spid = @@spid
if @ip in ('10.160.43.46','10.160.43.45', and so on)
begin
select syb_quit()
end
go
sp_modifylogin dbo_db,'dbo_db',restrictuser
go
grant execute on restrictuser to restrictedusergroup
go
I guess this would have to be set for all the logins that we want to restrict the
ipaddress too.
Execute sp_modifylogin

Cross Platform dump in sybase

Cross platform dump
http://www.sybase.com/content/1033627/18XPDL_1253_WP.pdf
after you run the code dump the database and copy to the location once you have done
this you can then load the database.
Sample of code to run
USE master
go
EXEC sp_dboption 'db','single user',true
go
USE master
go
EXEC sp_dboption  'db','dbo use only',true
go
USE cats_tky_dev1
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go
EXEC sp_dboption 'db','single user',false
go
USE master
go
EXEC sp_dboption'db','dbo use only',false
go
USE db
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go
USE master
go
EXEC sp_dboption 'db2','single user',true
go
USE master
go
EXEC sp_dboption 'db2','dbo use only',true
go
USE db2
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go
EXEC sp_dboption 'db2','single user',false
go
USE master
go
EXEC sp_dboption 'db2','dbo use only',false
go
USE db2
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go

Performance and Tuning


MEMUSAGE:
This is useful for validation your SQLserver memory configuration, dbcc
memusage reports three pieces of information.
The current allocation of memory within SQL server
Up to the 20 largest tables and or index currently in datacache.
Up to the 20 largest sored procs currently in procedure cache.
Examble for the code.
dbcc traceon (3604)
go
dbcc memusage
go
SP_SYSMON:
Sp_symon is a specialized system proc used to produce a statically report on the
sql server it will provide an overall performance picture for the adaptive
server(ASE) it is run on it will only work on system 11 and above.
The sytax for it is as followed

Sp_sysmon interval , section , applmon
The interval should be entered in “hh:mm:ss” format
It is not wise to run this on a daily basis as the system over head is to great this is
used for spot checks to see how the system is running. And example is to run
Sp_sysmon “00:15:00”

Sunday, June 7, 2009

dev usage

IF OBJECT_ID('dbo.sp_dba_devusage') IS NOT NULL
BEGIN
    DROP PROCEDURE dbo.sp_dba_devusage
    IF OBJECT_ID('dbo.sp_dba_devusage') IS NOT NULL
        PRINT '<<<>>>'
    ELSE
        PRINT '<<<>>>'
END
go


create proc sp_dba_devusage
as
set nocount on

select distinct
     name = d.name,
     db_size = str(sum(u.size) / 512, 10, 1) + " MB",
     dbid = d.dbid,
     created = convert(char(14), d.crdate, 107)
     from master.dbo.sysdatabases d, master.dbo.sysusages u
     where d.dbid = u.dbid
     group by d.dbid, u.dbid
     order by d.dbid

declare @vsize int
select @vsize = low
from master.dbo.spt_values
where type="E"
  and number = 3

select device = substring(name,1,15),
       vdevno = convert(tinyint,substring(convert(binary(4),low),@vsize,1)),
       "default disk?" = "      " + substring("NY",(status & 1)+1,1),
       "total (MB)" = str(round((high-low)/512.,2),7,2),
       used = str(round(isnull(sum(size),0)/512.,2),7,2),
       free = str(round(abs((high-low-isnull(sum(size),0))/512.),2),7,2)
from master.dbo.sysusages u,
     master.dbo.sysdevices d
where vstart between low and high
  and cntrltype=0
group by all name
  having cntrltype=0
order by vdevno


go
EXEC sp_procxmode 'dbo.sp_dba_devusage','unchained'
go
IF OBJECT_ID('dbo.sp_dba_devusage') IS NOT NULL
    PRINT '<<<>>>'
ELSE
    PRINT '<<<>>>'
go
USE sybsystemprocs
go
GRANT EXECUTE ON dbo.sp_dba_devusage TO public
go

check for blocks in database

IF OBJECT_ID('dbo.sp_dba_dblock') IS NOT NULL
BEGIN
    DROP PROCEDURE dbo.sp_dba_dblock
    IF OBJECT_ID('dbo.sp_dba_dblock') IS NOT NULL
        PRINT '<<<>>>'
    ELSE
        PRINT '<<<>>>'
END
go

create procedure sp_dba_dblock
as

declare @PRNTBUFFER varchar(150),
@CURRENTDB varchar(30),
@CURRENTDBID smallint,
        @LOCKCOUNT int

select @CURRENTDB = rtrim(db_name())
select @CURRENTDBID = db_id()

select @LOCKCOUNT = count(dbid)
       from master.dbo.syslocks
       where master.dbo.syslocks.dbid = @CURRENTDBID

if ( @LOCKCOUNT = 0 )
begin
select @PRNTBUFFER = " " + replicate("=",68)
print @PRNTBUFFER
select @PRNTBUFFER = " No Locks In Database : " + rtrim(@CURRENTDB)
print @PRNTBUFFER
                select @PRNTBUFFER = " " + replicate("=",68) 
                print @PRNTBUFFER 
end

else

  begin
                select @PRNTBUFFER = " " + replicate("=",68) 
                print @PRNTBUFFER 
                select @PRNTBUFFER = " Locks In Database : " + rtrim(@CURRENTDB) 
                print @PRNTBUFFER 
                select @PRNTBUFFER = " " + replicate("=",68)  
                print @PRNTBUFFER  

    select Spid = convert(char(4),master.dbo.syslocks.spid),
           SybaseUser = convert(char(12),master.dbo.syslogins.name),
           LockType = convert(char(14),master.dbo.spt_values.name),
           TableName = convert(char(18),object_name(master.dbo.syslocks.id)),
           PageNumber = convert(char(14),master.dbo.syslocks.page),
  UnixHost = convert(char(8),master.dbo.sysprocesses.hostname),
           UnixPid = convert(char(8),master.dbo.sysprocesses.hostprocess)
      from master.dbo.syslocks,
           master.dbo.spt_values,
           master.dbo.syslogins,
           master.dbo.sysprocesses
     where master.dbo.syslocks.type = master.dbo.spt_values.number
       and master.dbo.sysprocesses.suid = master.dbo.syslogins.suid
       and master.dbo.spt_values.type = "L"
       and master.dbo.syslocks.spid = master.dbo.sysprocesses.spid
       and master.dbo.syslocks.dbid = @CURRENTDBID
     order by 1,4,5
  end

return (0)


go
EXEC sp_procxmode 'dbo.sp_dba_dblock','unchained'
go
IF OBJECT_ID('dbo.sp_dba_dblock') IS NOT NULL
    PRINT '<<<>>>'
ELSE
    PRINT '<<<>>>'
go
USE sybsystemprocs
go
GRANT EXECUTE ON dbo.sp_dba_dblock TO public

gen database ddl


create procedure sp_dba_gendbddl @dbname varchar(32) = null
as

declare @db_name varchar(30),
@dbid smallint,
@segmap smallint,
@segs varchar(4),
@dev_frag varchar(30),
@frag_size char(10),
@sql_string varchar(255),
@alter_status tinyint,
@counter int,
@seq_no int,
    @numdbs     int

set nocount on

if @dbname is null select @dbname = "%"

-- Match databases if given else do them all
--
select @numdbs = count(*) from master.dbo.sysdatabases where name like @dbname

-- DB exists ?
--
if @numdbs = 0
begin
/* 17590, "The specified database does not exist." */
raiserror 17590
return (1)
end

-- Initialize dbids twmp table from sysdatabases
--
select dbid into #dbids from master.dbo.sysdatabases where name like @dbname

declare @curdbid smallint /* the one we're currently working on */
declare @dbdesc varchar(102) /* the total description for the db */
declare @bitdesc varchar(30) /* the bit description for the db */

-- Set @curdbid to the first dbid.
--
select @curdbid = min(dbid) from #dbids

create table #db_info(
    seq_no int not null,
    sql_string varchar(255) null
    )

-- Iterate through by dbid
--
while @curdbid is not NULL
begin

    /************************************************
     * Temporary table to hold individual fragments *
     * of SQL_STRING, numbered to preserve their *
     * correct sequence                             *
     ************************************************/

    delete #db_info

    -- Initialize variables
    select @alter_status = 0
    select @counter = 0
    select @seq_no = 0
    select @db_name = db_name(@curdbid)

    /* Declare a cursor to allow processing of each row individually */
    /* Select statement extracts relevant info from the system tables */
    /* ORDER BY clause is critical in order to ensure that all fragments */
    /* are processed in the correct sequence */

    declare get_db_info cursor for
    select db.dbid, usg.segmap, "device fragment"=substring(dev.name,1,15), "size(MB)" = str(usg.size/512.,10,0)
    from master.dbo.sysusages usg,
     master.dbo.sysdevices dev,
     master.dbo.sysdatabases db
    where vstart between low and high
    and cntrltype = 0
    and db.dbid = @curdbid
    and db.dbid =usg.dbid
    order by db.dbid,usg.lstart,dev.name


    -- Prepare initial SQL string
    select @sql_string = 'create database ' + @db_name + ' on '

    -- Store initial SQL_STRING in temporary table and
    -- number it to allow later extraction in the correct
    -- sequence
    insert into #db_info (seq_no, sql_string) values (@seq_no, @sql_string)

    -- Increment the sequence number
    select @seq_no = @seq_no + 1

    -- Open the cursor and fetch the first row
    open get_db_info

    fetch get_db_info into @dbid,@segmap,@dev_frag,@frag_size

    if (@@sqlstatus=2)
    begin
     select "No information found for database"
     close get_db_info
     deallocate cursor get_db_info
     return
    end

    while (@@sqlstatus = 0)
    begin

     if @alter_status = 0 /* Still part of original 'create database ...' command */
     begin
     if @segmap = 4 /* Must refer to log device */
        begin
     select @sql_string = '    log on ' + @dev_frag + ' = ' +
     ltrim(convert(varchar(20),@frag_size)) + char(10) + 'go' + char(10)
     select @alter_status = 1
     end
     else /* Must refer to data device */
     begin
     if @counter = 0 /* 1st data device of "create database ..." */
        begin
        select @sql_string = '    ' + @dev_frag + ' = ' + ltrim(convert(varchar(20),@frag_size))
        select @counter = @counter + 1
        end
     else /* Additional data device for "create database ..." */
        begin
        select @sql_string = '   ,' + @dev_frag + ' = ' + ltrim(convert(varchar(20),@frag_size))
        end
     end
     end
     else /* Must be an alter database command */
     begin

     select @sql_string = 'alter database ' + @db_name

     insert into #db_info (seq_no, sql_string) values (@seq_no, @sql_string)

     select @seq_no = @seq_no + 1

            -- Log = 4 or data
            --
     if @segmap = 4
     select @sql_string = '    log on ' + @dev_frag + ' = ' +
     ltrim(convert(varchar(20),@frag_size)) + char(10) + 'go' + char(10)
     else
     select @sql_string = '    on ' + @dev_frag + ' = ' +
     ltrim(convert(varchar(20),@frag_size)) + char(10) + 'go' + char(10)
     end

     insert into #db_info (seq_no, sql_string) values (@seq_no, @sql_string)

     select @seq_no = @seq_no + 1

     -- Get next row
     fetch get_db_info into @dbid,@segmap,@dev_frag,@frag_size
    end

    close get_db_info
    deallocate cursor get_db_info

    -- Select each piece of SQL from temporary table ordering by */
    -- sequence number */
    --
    declare print_createdb_cursor cursor for
     select sql_string
     from #db_info
     order by seq_no
     for read only

    open print_createdb_cursor

    fetch print_createdb_cursor into @sql_string

    while (@@sqlstatus = 0)
    begin
     print @sql_string
     fetch print_createdb_cursor into @sql_string
    end

    close print_createdb_cursor
    deallocate cursor print_createdb_cursor

   -- Get next dbid.
--
select @curdbid = min(dbid) from #dbids where dbid > @curdbid

end

drop table #db_info
drop table #dbids

return(0)

check table space

IF OBJECT_ID('dbo.sp_dba_dbspace') IS NOT NULL

BEGIN

    DROP PROCEDURE dbo.sp_dba_dbspace

    IF OBJECT_ID('dbo.sp_dba_dbspace') IS NOT NULL

        PRINT '<<<>>>'

    ELSE

        PRINT '<<<>>>'

END

go


create procedure sp_dba_dbspace

as

set nocount on


declare @data_size float,

@log_size float,

@psize_kb float,

@log_id int,

@rsrvTTL int,

@log_segment int,

@message char(80)


/* get the segmap mask for log only segments */


select @log_segment = number

from master..spt_values

where name = "log only"

if @@error != 0 return


/* get the id of the syslogs table */


select @log_id = id

from sysobjects where name = "syslogs"

        if @@error != 0 return


/* get page size from system proc values table */


select distinct @psize_kb = convert(float, low) / 1024

from master..spt_values

where number = 1 and type = "E"

if @@error != 0 return


/* get the db size excluding the log segment size */


select distinct @data_size = sum(size)

from master..sysusages

where dbid = db_id() and segmap != @log_segment

if @@error != 0 return


/* get the log segment size */


select distinct @log_size = sum(size)

from master..sysusages

where dbid = db_id() and segmap = @log_segment

if @@error != 0 return

if @log_size is NULL

  select @log_size = 0   /* case where the db has no log segment */

/* print out the overall database stats */


        select @message = " " + replicate("=",68)

        print @message

select DbName = rtrim(db_name()),

      DbSize = ltrim(str(sum(@data_size + @log_size) * @psize_kb, 12, 0) + " KB"),

      DataSegments = ltrim(str(@data_size * @psize_kb, 10, 0) + " KB"),

      LogSegments = ltrim(str(@log_size * @psize_kb, 10, 0) + " KB")

        if @@error != 0 return


        select @message = " " + replicate("=",68)

        print @message


/* get page counts for all tables except syslogs */


select

               o.name "Tname",

               i.name "Iname",

               i.segment,

      i.id,

      i.indid,

      Rrows = rowcnt(i.doampg),

      rsrv = (reserved_pgs(i.id,i.doampg) + reserved_pgs(i.id,i.ioampg)),

      data = data_pgs(i.id,i.doampg),

      idx = data_pgs(i.id,i.ioampg),

      unused = ((reserved_pgs(i.id,i.doampg) + reserved_pgs(i.id,i.ioampg)) -

  (data_pgs(i.id,i.doampg) + data_pgs(i.id,i.ioampg)))

               into #tableCount

      from sysobjects o, sysindexes i

               where o.id = i.id

      and o.id != @log_id

      if @@error != 0 return


       /* print out results

* order by system tables, system tables nonclustered idx

* then user tables with no clustered idx, clustered idx tabs and

* finally non clustered idx 

*/


               print "             SYSTEM TABLES"

      select @message = " " + replicate("=",68) 

      print @message


               select rtrim(Tname) "TableName",

               rtrim(Iname) "IndexName",

               ltrim(str(convert(float,Rrows),12,0)) "RowCount",

               ltrim(str(convert(float,rsrv),10,0)) "ReservedPages",

               ltrim(str(convert(float,rsrv)*@psize_kb,10,2)+" KB") "Space",

               ltrim(str(convert(float,data),10,0)) "DataPages",

               ltrim(str(convert(float,idx),10,0)) "IndexPages",

               ltrim(str(convert(float,unused),10,0)) "UnusedPages"

               from #tableCount tp 

               where tp.id <>

               and ( tp.indid = 0 or tp.indid = 1 )

               order by id 


               select @message = " " + replicate("=",68)

               print @message 

               print "  NON CLUSTERED INDEXES ON SYSTEM TABLES" 

               select @message = " " + replicate("=",68)  

               print @message 

               


               select rtrim(Tname) "TableName",

               rtrim(Iname) "IndexName",

               ltrim(str(convert(float,rsrv),10,0)) "ReservedPages", 

               ltrim(str(convert(float,rsrv)*@psize_kb,10,2)+" KB") "Space", 

               ltrim(str(convert(float,idx),10,0)) "IndexPages",

               ltrim(str(convert(float,unused),10,0)) "UnusedPages" 

               from #tableCount tp  

               where tp.id <>

               and tp.indid > 1  

               order by id


               select @message = " " + replicate("=",68)

               print @message

               print "         USER TABLES WITH NO CLUSTERED INDEXES"

      select @message = " " + replicate("=",68) 

      print @message



               select rtrim(Tname) "TableName",

      ltrim(str(convert(float,Rrows),12,0)) "RowCount",

      ltrim(str(convert(float,rsrv),10,0)) "ReservedPages",

      ltrim(str(convert(float,rsrv)*@psize_kb,10,2)+" KB") "Space",

      ltrim(str(convert(float,data),10,0)) "DataPages",

      ltrim(str(convert(float,unused),10,0)) "UnusedPages"

      from #tableCount tp 

      where tp.id > 100

      and tp.indid = 0

      order by Tname


               select @message = " " + replicate("=",68) 

               print @message 

               print "            USER TABLES WITH CLUSTERED INDEX" 

               select @message = " " + replicate("=",68)  

               print @message 



               select rtrim(Tname) "TableName",

               rtrim(Iname) "IndexName",

      ltrim(str(convert(float,Rrows),12,0)) "RowCount",

               ltrim(str(convert(float,rsrv),10,0)) "ReservedPages",

      ltrim(str(convert(float,rsrv)*@psize_kb,10,2)+" KB") "Space",

      ltrim(str(convert(float,data),10,0)) "DataPages",

               ltrim(str(convert(float,idx),10,0)) "IndexPages",

      ltrim(str(convert(float,unused),10,0)) "UnusedPages"

               from #tableCount tp

               where tp.id > 100

               and tp.indid = 1

      order by Tname


               select @message = " " + replicate("=",68)

               print @message

               print "        NON CLUSTERED INDEXES ON USER TABLES"

               select @message = " " + replicate("=",68)

               print @message 

               


               select rtrim(Tname) "TableName",

               rtrim(Iname) "IndexName",

      ltrim(str(convert(float,rsrv),12,0)) "ReservedPages",

      ltrim(str(convert(float,rsrv)*@psize_kb,10,2)+" KB") "Space",

      ltrim(str(convert(float,idx),10,0)) "IndexPages", 

               ltrim(str(convert(float,unused),10,0)) "UnusedPages"

               from #tableCount tp 

               where tp.id > 100 

               and tp.indid > 1 

      order by Tname


        /* now get space for syslogs */


insert into #tableCount

select

               o.name,

               i.name,

               i.segment,

      i.id,

      i.indid,

               rowcnt(i.doampg),

      reserved_pgs(i.id, i.doampg),

      data_pgs(i.id,i.doampg),

      0,

      unused = reserved_pgs(i.id, i.doampg) - data_pgs(i.id,i.doampg)

      from sysobjects o, sysindexes i

      where o.id = i.id 

      and o.id = @log_id

      if @@error != 0 return


        /* compute summary results showing Total data seg allocated

* whats been reserved and unused.

* compute a usage as a percentage  

*/


select @message = " " + replicate("=",68) 

        print @message

print "      SUMMARY RESULTS " 


        /* if log on its own segment then use @log_size else use data_size  */

 

        if @log_size != 0

         begin


 select

DataSegTTL = ltrim(str(@data_size * @psize_kb, 10, 0) + " KB"),

Reserved = ltrim(str(convert(float,sum(rsrv))*@psize_kb,10,0)+" KB"),

Objects = ltrim(str(convert(float,sum(data))*@psize_kb,10,0)+" KB"),

Indixes = ltrim(str(convert(float,sum(idx))*@psize_kb,10,0)+" KB"),

FreeSpace =str((@data_size*@psize_kb)-(sum(rsrv)*@psize_kb)) + " KB",

                Usage = str((sum(rsrv)*@psize_kb)/(@data_size * @psize_kb) * 100,6,2) + " % Used" 

   from #tableCount

   where id != @log_id

   if @@error != 0 return


          select

LogSegTTL = str(@log_size * @psize_kb, 10, 0) + " KB",

Reserved = str(rsrv*@psize_kb) + " KB",

                 FreeSpace = str((@log_size*@psize_kb)-(rsrv*@psize_kb)) + " KB",

Usage = str((((rsrv*@psize_kb)/(@log_size * @psize_kb)) * 100),6,2) + " % Used"

   from #tableCount

   where id = @log_id

   if @@error != 0 return

         end


        else


begin


                select @message = "DATA AND LOG SHARE SAME SEGMENT"

                print @message


                /* get the total of reserved pages from #tableCount */


                select @rsrvTTL = sum(rsrv) from #tableCount

                if @@error != 0 return


select

DataSegTTL = ltrim(str(@data_size * @psize_kb, 10, 0) + " KB"),

Reserved = ltrim(str(convert(float,sum(rsrv))*@psize_kb,10,0)+" KB"),

Objects = ltrim(str(convert(float,sum(data))*@psize_kb,10,0)+" KB"),

Indixes = ltrim(str(convert(float,sum(idx))*@psize_kb,10,0)+" KB"),

                FreeSpace = str((@data_size*@psize_kb)-(@rsrvTTL*@psize_kb)) + " KB",

Usage = str((@rsrvTTL*@psize_kb)/(@data_size * @psize_kb) * 100,6,2) + " % Used"

from #tableCount

where id != @log_id


                select

                DataSegTTL = str(@data_size * @psize_kb, 10, 0) + " KB",

                LogReserved = str(rsrv*@psize_kb) + " KB",

                FreeSpace = str((@data_size*@psize_kb)-(@rsrvTTL*@psize_kb)) + " KB",

                Usage = str((((@rsrvTTL*@psize_kb)/(@data_size * @psize_kb)) * 100),6,2) + " % Used"

                from #tableCount

                where id = @log_id

                if @@error != 0 return 

         end        


                select @message = " " + replicate("=",68)

       print @message

                select @message = "TOTAL SPACE RESERVED PER SEGMENT" 

       print @message


          select

          s.name "SegName",

          Reserved = ltrim(str(convert(float,sum(rsrv))*@psize_kb,10,0)+" KB")

          from syssegments s, #tableCount t

          where s.segment = t.segment

          group by s.name

          order by s.segment


                select @message = " " + replicate("=",68)

                print @message


       /* how much space the current db uses on each device */


select size = convert(float, high-low+1) * @psize_kb,

alloc = convert(float, sum(size)) * @psize_kb,

device = name,

total_alloc = convert(float, 0)

into #devSum

from master..sysusages, master..sysdevices

where vstart >= low and vstart <= high and cntrltype = 0 

and dbid = db_id()

group by name

if @@error != 0 return


/* update total usage for each device. */


update #devSum

set total_alloc = ( select sum(su.size) from master..sysusages su,

   master..sysdevices sd

   where vstart >= low and vstart <= high and cntrltype = 0

   and #devSum.device = sd.name

   )

   if @@error != 0 return


   update #devSum

   set total_alloc = total_alloc * @psize_kb

   if @@error != 0 return


/* add summary lines to the device sum table */


insert #devSum

select sum(size), sum(alloc), "TOTAL", sum(total_alloc)

from #devSum

if @@error != 0 return


/* now print stats */

select @message = "      DISK ACTUAL USAGE BY DEVICE FOR: " + db_name()

        print @message

        select @message = " " + replicate("=",68)

print @message


select DeviceName = device,

      Size = str(size, 10, 0) + " KB",

      ThisDb = str(alloc, 10, 0) + " KB",

      OtherDb = str(total_alloc - alloc, 10, 0) + " KB",

      UnAlloc = str(size - total_alloc, 10 ,0) + " KB",

      Usage = str(total_alloc/size *100,6,2) + " % Used"

      from #devSum

      where device != "TOTAL"

      order by device

      if @@error != 0 return


        select @message = " " + replicate("=",68)

print @message


        select TOTAL = device,

               Size = str(size, 10, 0) + " KB",

               ThisDb = str(alloc, 10, 0) + " KB",

               OtherDb = str(total_alloc - alloc, 10, 0) + " KB",

               UnAlloc = str(size - total_alloc, 10 ,0) + " KB",

      Usage = str(total_alloc/size *100,6,2) + " % Used"

               from #devSum 

               where device = "TOTAL" 

               if @@error != 0 return


        select @message = " " + replicate("=",68)

        print @message 


drop table #devSum

drop table #tableCount


return 0



go

EXEC sp_procxmode 'dbo.sp_dba_dbspace','unchained'

go

IF OBJECT_ID('dbo.sp_dba_dbspace') IS NOT NULL

    PRINT '<<<>>>'

ELSE

    PRINT '<<<>>>'

go

USE sybsystemprocs

go

GRANT EXECUTE ON dbo.sp_dba_dbspace TO public

go