samedi 24 janvier 2015

Updating value in temporary table using select statement



Insert into #Temp(Rownumber, Percentage)
select RowNumber,
(MatchFirstName.PercentMatch * FunctionWeights.FunctionWeight)
from dbo.MatchFirstName(@FirstName), dbo.FunctionWeights
where FunctionWeights.FunctionName = 'MatchZIP'


In FunctionWeights table, I have weights column and FunctionName column that stores different function names.


dbo.MatchZIP(@ZIP) is the TVF here. Now , I have a table called FunctionWeights that stores a constant value corresponding to these function names.


Before the value is inserted into Temp table in Percentage column, I want it to retrieve the constant value corresponding to the function name that select statement has and multiply it which percentage value which was retrieved from the function. How can I do this?


With above query, multiplied value is not retrieved in the percentage column of Temp table but only the PercentageMatch value from TVF.


SNAPSHOTS:


FunctionWeights Table


select * from FunctionWeights


Insert into #Temp from select





Aucun commentaire:

Enregistrer un commentaire