Just one small comment ---> and the code :-D
T-SQL Allgemein
--for the first HP compute a linear depreciation from Deprecistion Base EQ-((RV-EQ)/HP)* Age = RV
Kategorie --for the first HP compute a linear depreciation from Deprecistion Base EQ-((RV-EQ)/HP)* Age = RV
--for the first HP compute
a linear depreciation from Deprecistion Base EQ-((RV-EQ)/HP)* Age = RV
alter table OP_FERM_MASTER_20081111..residualvalue add DepreciationBase real
update OP_FERM_MASTER_20081111..residualvalue set DepreciationBase = T1.Depreciation_Base
from OP_FERM_MASTER_20081111..residualvalue left join
(select derivative_id,listitemid, Contractual_HP as Depreciation_Base
from OP_FERM_MASTER_20081111..derivative do,derivative ds,db_vec_storage dvs
where convert(varchar,listitemid) = left(derivative_name,charindex('-',derivative_name)-2)
and left(derivative_name,charindex('-',derivative_name)-2) collate SQL_Latin1_General_CP1_CI_AS = left(derivativename,charindex('-',derivativename)-2)
and category = 'Depreciation Base') as T1
on (T1.ListItemId =OP_FERM_MASTER_20081111..residualvalue.ListItemId)
alter table OP_FERM_MASTER_20081111..residualvalue add minHP real
DECLARE @inc int
set @inc = 1
While @inc<36
BEGIN
DECLARE @sql1 varchar(8000)
set @sql1 = 'update OP_FERM_MASTER_20081111..residualvalue set minHP='+convert(varchar,@inc+1)+
' where hp'+convert(varchar,@inc) + '= hp'+convert(varchar,@inc+1)
exec(@sql1)
set @inc=@inc+1
END
set @inc = 1
While @inc<36
BEGIN
DECLARE @sql2 varchar(8000)
set @sql2 = 'update OP_FERM_MASTER_20081111..residualvalue set hp'+convert(varchar,@inc)+
'=DepreciationBase -((DepreciationBase - hp'+convert(varchar,@inc)+')/MINHP)*'+convert(varchar,@inc)+ ' where hp'+convert(varchar,@inc) + '= hp'+convert(varchar,@inc+1)
exec(@sql2)
set @inc=@inc+1
END
Der Kommentar hilft weiter.........
Gruß JJR
alter table OP_FERM_MASTER_20081111..residualvalue add DepreciationBase real
update OP_FERM_MASTER_20081111..residualvalue set DepreciationBase = T1.Depreciation_Base
from OP_FERM_MASTER_20081111..residualvalue left join
(select derivative_id,listitemid, Contractual_HP as Depreciation_Base
from OP_FERM_MASTER_20081111..derivative do,derivative ds,db_vec_storage dvs
where convert(varchar,listitemid) = left(derivative_name,charindex('-',derivative_name)-2)
and left(derivative_name,charindex('-',derivative_name)-2) collate SQL_Latin1_General_CP1_CI_AS = left(derivativename,charindex('-',derivativename)-2)
and category = 'Depreciation Base') as T1
on (T1.ListItemId =OP_FERM_MASTER_20081111..residualvalue.ListItemId)
alter table OP_FERM_MASTER_20081111..residualvalue add minHP real
DECLARE @inc int
set @inc = 1
While @inc<36
BEGIN
DECLARE @sql1 varchar(8000)
set @sql1 = 'update OP_FERM_MASTER_20081111..residualvalue set minHP='+convert(varchar,@inc+1)+
' where hp'+convert(varchar,@inc) + '= hp'+convert(varchar,@inc+1)
exec(@sql1)
set @inc=@inc+1
END
set @inc = 1
While @inc<36
BEGIN
DECLARE @sql2 varchar(8000)
set @sql2 = 'update OP_FERM_MASTER_20081111..residualvalue set hp'+convert(varchar,@inc)+
'=DepreciationBase -((DepreciationBase - hp'+convert(varchar,@inc)+')/MINHP)*'+convert(varchar,@inc)+ ' where hp'+convert(varchar,@inc) + '= hp'+convert(varchar,@inc+1)
exec(@sql2)
set @inc=@inc+1
END
Der Kommentar hilft weiter.........
Gruß JJR