Hi
I have to add Disk capacity trending information to data. Need to add future dates with potential disk capacity based on past dates. I have created some dummy data as follows:
if object_id('tempdb..#dummytable') is not null drop table #dummytable
create table #dummytable
(
ServerName varchar(10)
,SampleDate datetime
,DiskUsed decimal(5)
,DiskCapacity decimal(5)
)
insert into #dummytable
select 'abcdefgh' ,'20140630' ,100 ,1000
union all
select 'abcdefgh' ,'20140531' ,90 ,1000
union all
select 'abcdefgh' ,'20140430' ,80 ,1000
union all
select 'abcdefgh' ,'20140331' ,70 ,1000
union all
select 'abcdefgh' ,'20140228' ,60 ,1000
union all
select 'zyxwvuts' ,'20140628' ,60 ,500
union all
select 'zyxwvuts' ,'20140528' ,50 ,500
union all
select 'zyxwvuts' ,'20140428' ,40 ,500
union all
select 'zyxwvuts' ,'20140328' ,30 ,500
union all
select 'zyxwvuts' ,'20140228' ,20 ,500
select * from #dummytable
Need to add 6 months of the last day of the month from the last date for each server
Need to calculate the additional Disk Used based on the last 6 months data
The end Disk Used data can't be more then the DiskCapacity
I want to see these additional records:
ServerName-----------SampleDate------------DiskUsed--------DiskCapacity
abcdefgh---------------2014-07-31--------------110------------------1000
abcdefgh---------------2014-08-31--------------120------------------1000
abcdefgh---------------2014-09-30--------------130------------------1000
abcdefgh---------------2014-10-31--------------140------------------1000
abcdefgh---------------2014-11-30--------------150------------------1000
abcdefgh---------------2014-12-31--------------160------------------1000
zyxwvuts---------------2014-07-31--------------70--------------------1000
zyxwvuts---------------2014-08-31--------------80--------------------1000
zyxwvuts---------------2014-09-30--------------90--------------------1000
zyxwvuts---------------2014-10-31--------------100-------------------1000
zyxwvuts---------------2014-11-30--------------110-------------------1000
zyxwvuts---------------2014-12-31--------------120-------------------1000
The DiskUsed is calculated as the average monthly gain from first to last month spread over the next 6 months
Can this be done using set based sql, or do I have to use a cursor
regards
Mark
I have to add Disk capacity trending information to data. Need to add future dates with potential disk capacity based on past dates. I have created some dummy data as follows:
if object_id('tempdb..#dummytable') is not null drop table #dummytable
create table #dummytable
(
ServerName varchar(10)
,SampleDate datetime
,DiskUsed decimal(5)
,DiskCapacity decimal(5)
)
insert into #dummytable
select 'abcdefgh' ,'20140630' ,100 ,1000
union all
select 'abcdefgh' ,'20140531' ,90 ,1000
union all
select 'abcdefgh' ,'20140430' ,80 ,1000
union all
select 'abcdefgh' ,'20140331' ,70 ,1000
union all
select 'abcdefgh' ,'20140228' ,60 ,1000
union all
select 'zyxwvuts' ,'20140628' ,60 ,500
union all
select 'zyxwvuts' ,'20140528' ,50 ,500
union all
select 'zyxwvuts' ,'20140428' ,40 ,500
union all
select 'zyxwvuts' ,'20140328' ,30 ,500
union all
select 'zyxwvuts' ,'20140228' ,20 ,500
select * from #dummytable
Need to add 6 months of the last day of the month from the last date for each server
Need to calculate the additional Disk Used based on the last 6 months data
The end Disk Used data can't be more then the DiskCapacity
I want to see these additional records:
ServerName-----------SampleDate------------DiskUsed--------DiskCapacity
abcdefgh---------------2014-07-31--------------110------------------1000
abcdefgh---------------2014-08-31--------------120------------------1000
abcdefgh---------------2014-09-30--------------130------------------1000
abcdefgh---------------2014-10-31--------------140------------------1000
abcdefgh---------------2014-11-30--------------150------------------1000
abcdefgh---------------2014-12-31--------------160------------------1000
zyxwvuts---------------2014-07-31--------------70--------------------1000
zyxwvuts---------------2014-08-31--------------80--------------------1000
zyxwvuts---------------2014-09-30--------------90--------------------1000
zyxwvuts---------------2014-10-31--------------100-------------------1000
zyxwvuts---------------2014-11-30--------------110-------------------1000
zyxwvuts---------------2014-12-31--------------120-------------------1000
The DiskUsed is calculated as the average monthly gain from first to last month spread over the next 6 months
Can this be done using set based sql, or do I have to use a cursor
regards
Mark