2011-01-19 76 views
0

我已經寫了下面的代碼,並得到以下錯誤,我相信它與我如何加入國家表,但不能解決如何修理。任何人都可以點我在正確的方向,請更新Msg 4104,Level 16,State 1,Procedure cst_priceimporter,Line 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' 

回答

0

的設置部位應該沒有任何表名,你只能反正更新之一。 此外,由於你有別名國家爲C,則需要使用別名

update country 
set  price = 1/c.price 

我認爲它出現了兩次

相關問題