1 ETQ000 ================================================== 1 ETQ399 Executing SQL script '..\var\MSSSPACE.TSQL'. 2 ETQ399 Connecting to database 'mss'. 4 ETQ393 START SELRESULT01>> 4 ETQ010 Date & Time: 20200722141648 3 ETQ398 SQL: SELECT CAST(SUM(FREE) as decimal(15)) FROM (select (((size/128) - 3 ETQ398XSQL: FILEPROPERTY(name, 'SpaceUsed')/128)) as FREE from sysfiles where 3 ETQ398XSQL: groupid=1) as d 4 ETQ394 "13900" 4 ETQ395 END SELRESULT01>> 4 ETQ393 START SELRESULT02>> 3 ETQ398 SQL: set nocount on declare @cmd varchar(256) declare @drive char(1) 3 ETQ398XSQL: declare @drive_freespace int declare @drive_sum int declare 3 ETQ398XSQL: @free_space int declare @free_space_log int declare @free_space_no_log 3 ETQ398XSQL: int declare @growth int declare @log_size int declare @max_size int 3 ETQ398XSQL: declare @root_lower char(4) declare @root_upper char(4) declare @size 3 ETQ398XSQL: int declare @sum_drive_freespace int declare @sum_drive_sum int create 3 ETQ398XSQL: table #drives_sys (drive char(1)) create table #drives_xp (drive 3 ETQ398XSQL: char(1), drive_freespace int) create table #free_space (drive char(1), 3 ETQ398XSQL: drive_sum int, drive_freespace int, log char(1)) insert into 3 ETQ398XSQL: #drives_sys select substring(filename,1,1) from sysfiles where status 3 ETQ398XSQL: & 0x40 = 0 insert into #drives_xp exec master..xp_fixeddrives delete 3 ETQ398XSQL: from #drives_xp where upper(drive) not in (select * from #drives_sys) 3 ETQ398XSQL: and lower(drive) not in (select * from #drives_sys) delete from 3 ETQ398XSQL: #drives_sys declare calc_sum cursor for select drive, drive_freespace 3 ETQ398XSQL: from #drives_xp open calc_sum fetch next from calc_sum into 3 ETQ398XSQL: @drive,@drive_freespace while (@@fetch_status <> -1) begin 3 ETQ398XSQL: if(@@fetch_status <> -2) begin select @root_upper = upper(@drive) + 3 ETQ398XSQL: ':\%' select @root_lower = lower(@drive) + ':\%' select @drive_sum 3 ETQ398XSQL: = 0 declare calc_drive_sum cursor for select size, maxsize, 3 ETQ398XSQL: growth from sysfiles where ( filename like @root_upper or filename 3 ETQ398XSQL: like @root_lower ) and status & 0x40 = 0 open calc_drive_sum 3 ETQ398XSQL: fetch next from calc_drive_sum into @size, @max_size, @growth while 3 ETQ398XSQL: (@@fetch_status <> -1) begin if(@@fetch_status <> -2) 3 ETQ398XSQL: if(@max_size = -1 and @growth >0) select @drive_sum = @drive_sum 3 ETQ398XSQL: + @drive_freespace else if(@max_size > 0 and @growth >0) 3 ETQ398XSQL: select @drive_sum = @drive_sum + (@max_size - @size) / 1024 * 8 3 ETQ398XSQL: fetch next from calc_drive_sum into @size, @max_size, @growth end 3 ETQ398XSQL: close calc_drive_sum deallocate calc_drive_sum if @drive_sum >= 3 ETQ398XSQL: @drive_freespace insert into #free_space values(@drive, 3 ETQ398XSQL: @drive_freespace, @drive_freespace, 'N') else insert into 3 ETQ398XSQL: #free_space values(@drive, @drive_sum, @drive_freespace, 'N') end 3 ETQ398XSQL: fetch next from calc_sum into @drive, @drive_freespace end close 3 ETQ398XSQL: calc_sum deallocate calc_sum drop table #drives_xp insert into 3 ETQ398XSQL: #drives_sys select substring(filename,1,1) from sysfiles where status 3 ETQ398XSQL: & 0x40 = 64 declare log_on_drive cursor for select drive from 3 ETQ398XSQL: #drives_sys open log_on_drive fetch next from log_on_drive into @drive 3 ETQ398XSQL: while (@@fetch_status <> -1) begin if(@@fetch_status <> -2) update 3 ETQ398XSQL: #free_space set log = 'Y' where drive in (upper(@drive), 3 ETQ398XSQL: lower(@drive)) fetch next from log_on_drive into @drive end close 3 ETQ398XSQL: log_on_drive deallocate log_on_drive drop table #drives_sys select 3 ETQ398XSQL: @log_size = (select sum(size)/1024*8 from sysfiles where status & 0x40 3 ETQ398XSQL: = 64) if exists( select * from #free_space where log = 'Y') if 3 ETQ398XSQL: @log_size < 1024 begin select @sum_drive_sum = (select 3 ETQ398XSQL: sum(drive_sum) from #free_space where log = 'Y') select 3 ETQ398XSQL: @sum_drive_freespace = (select sum(drive_freespace) from #free_space 3 ETQ398XSQL: where log = 'Y') if @sum_drive_freespace - @sum_drive_sum < 1024 - 3 ETQ398XSQL: @log_size select @free_space_log = @sum_drive_freespace - (1024 - 3 ETQ398XSQL: @log_size) else select @free_space_log = @sum_drive_sum end 3 ETQ398XSQL: else select @free_space_log = (select sum(drive_sum) from 3 ETQ398XSQL: #free_space where log = 'Y') else select @free_space_log = 0 if 3 ETQ398XSQL: exists( select * from #free_space where log = 'N') select 3 ETQ398XSQL: @free_space_no_log = (select sum(drive_sum) from #free_space where log 3 ETQ398XSQL: = 'N') else select @free_space_no_log = 0 if @free_space_log < 0 3 ETQ398XSQL: select @free_space = @free_space_no_log else select @free_space 3 ETQ398XSQL: = @free_space_log + @free_space_no_log drop table #free_space 3 ETQ398XSQL: select CAST(@free_space as int) 4 ETQ394 "353228" 4 ETQ395 END SELRESULT02>> 1 ETQ000 ================================================== 4 ETQ010 Date & Time: 20200722141648 1 ETQ003 exit code: "0"