2013-07-23 46 views
-1

我試過這段代碼:MERGE語句收益率綁定錯誤

Merge fact_table as target 
using(select top 1 idDateDeb,PK_Date, Week_Of_Year from dbo.dim_date_Debut) 
as source 
on cast(source.PK_Date as date)=cast(dbo.FACT_TABLE.DATE_DEBUT_ALRM as date) 
when matched then update set target.ID_TEMP_DEB=source.idDateDeb; 

但我得到這個錯誤:

Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "dbo.FACT_TABLE.DATE_DEBUT_ALRM" could not be bound.

我試圖做類似this question

+1

我建議不要鏈接到另一個問題,而是描述你在這裏要做的事情(尤其是如果它與另一個問題有*不同),否則這應該作爲一個副本關閉。 –

回答

1

嘗試:

Merge dbo.fact_table as target 
using(select top 1 idDateDeb,PK_Date, Week_Of_Year from dbo.dim_date_Debut) 
as source 
on cast(source.PK_Date as date)=cast(target.DATE_DEBUT_ALRM as date) 
when matched then update set target.ID_TEMP_DEB=source.idDateDeb; 

你別名(dbo.fact_table作爲target,所以解析器會期待看到target,不dbo.FACT_TABLE

+0

我做了這段代碼,但我沒有在Fact_Table上設置IdDateDeb:s:受影響的行s我認爲當數據插入fact_Table時,我必須做triiger getId並將其放在id_tem_deb上,但我不知道如何去做 – user2586714

+0

我試過這段代碼,但O行影響到了什麼問題?使用 合併fact_table作爲靶然後匹配 更新集時(選擇頂部1 idDatefin,PK_Date_fin, WEEK_OF_YEAR 從dbo.dim_date_fin)作爲對鑄造源 (source.PK_Date_fin如日期)=流延(如target.DATE_fin_ALaRM日期) target.ID_TEMP_DEB = source.idDatefin, target.NUMEROSEMAINE = source.Week_Of_Year; heeeeelp請;( – user2586714