2011-01-19 2 views
0

J'ai écrit le code suivant et obtenir l'erreur ci-dessous, je crois que c'est à voir avec comment je suis rejoindre à la table de pays, mais ne peut pas calculer comment réparer. Quelqu'un peut-il me diriger dans la bonne direction s'il vous plaîtMsg 4104, niveau 16, état 1, procédure cst_priceimporter, ligne 37

Msg 4104, Level 16, State 1, Procedure cst_priceimporter, Line 37 
The multi-part identifier "country.price" could not be bound. 

 

create procedure cst_priceimporter as 



declare @todayDt datetime 
declare @dtfirst int 
declare @dtweek int 
declare @iswkday bit 


select @todayDt = convert(varchar,getdate(),101) 

set @dtfirst = @@datefirst - 1 
set @dtweek = datepart(weekday, @todayDt) -1 



if (@dtfirst + @dtweek) % 7 = 0 
    begin 


     set @todaydt = @todaydt- 2 

     update SecPriceHist 
     set  fxrate = 1/fxrate 
     from SecPriceHist sph 
     join sec s 
     on  sph.id = s.id 
     and  sph.priceSource = 'DFLT' 
     and  sph.hdate = @todayDt 
     and  sph.dateStamp between DATEADD(mi,-1,getdate()) and getdate() 
     and  s.sectype <2 and s.country not in ('SupraNational','ZMultiCountry') 
     and  sph.id <> 'SEK' 

     update country 
     set  country.price = 1/country.price 
     from country c 
     join sec s 
     on  s.country = c.country 
     and  s.dateStamp between DATEADD(mi,-1,getdate()) and getdate() 
     and  s.sectype <2 and s.country not in ('SupraNational','ZMultiCountry') 
     and  s.id <> 'SEK' 
     join secpricehist sph 
     on  sph.id = s.id 
     and  s.country = c.country 
     and  sph.priceSource = 'DFLT' 
     and  sph.hdate = @todayDt 
     and  sph.dateStamp between DATEADD(mi,-1,getdate()) and getdate() 
     and  s.sectype <2 and s.country not in ('SupraNational','ZMultiCountry') 
     and  sph.id <> 'SEK' 






    end 
else 
     set @todaydt = @todaydt- 1 

     update SecPriceHist 
     set  fxrate = 1/fxrate 
     from SecPriceHist sph 
     join sec s 
     on  sph.id = s.id 
     and  sph.priceSource = 'DFLT' 
     and  sph.hdate = @todayDt 
     and  sph.dateStamp between DATEADD(mi,-1,getdate()) and getdate() 
     and  s.sectype <2 and s.country not in ('SupraNational','ZMultiCountry') 
     and  sph.id <> 'SEK' 


     update country 
     set  country.price = 1/country.price 
     from country c 
     join sec s 
     on  s.country = c.country 
     and  s.dateStamp between DATEADD(mi,-1,getdate()) and getdate() 
     and  s.sectype <2 and s.country not in ('SupraNational','ZMultiCountry') 
     and  s.id <> 'SEK' 
     join secpricehist sph 
     on  sph.id = s.id 
     and  s.country = c.country 
     and  sph.priceSource = 'DFLT' 
     and  sph.hdate = @todayDt 
     and  sph.dateStamp between DATEADD(mi,-1,getdate()) and getdate() 
     and  s.sectype <2 and s.country not in ('SupraNational','ZMultiCountry') 
     and  sph.id <> 'SEK' 

Répondre

0

La partie SET de mise à jour ne devrait pas avoir un nom de table, vous ne pouvez mettre à jour un de toute façon. En outre, depuis que vous avez aliasé pays C, vous devez utiliser l'alias

update country 
set  price = 1/c.price 

Je pense qu'il se produit deux fois

Questions connexes