2012-08-30 84 views
0

我創建了一個存儲過程,我在其中調用兩個函數。sql server多部分標識符「」無法綁定存儲過程

我得到一個錯誤:

Msg 4104, Level 16, State 1, Procedure Add_Translation, Line 25
The multi-part identifier ".word" could not be bound.

這是我的存儲過程:

ALTER PROCEDURE [dbo].[Add_Translation] 
    @english nvarchar(70), 
    @kurdish nvarchar(70), 
    @english_category int, 
    @kurdish_category int, 
    @result int out 
AS 
BEGIN 
    SET NOCOUNT ON; 

    if @english is not null and @kurdish is not null and @english_category is not null and @kurdish_category is not null 
    begin 
     declare @intEnId int=-1; 
     exec @intEnId = Check_English_word @text = @english; 

     declare @identityEnglish int; 
     declare @identityKurdish int; 

     if @intEnId = -1 
     begin 
      insert into english_table values(@english, @english_category); 
      set @identityEnglish = SCOPE_IDENTITY(); 
     end 
     else 
     begin 
      set @identityEnglish = (select e.english_id from english_table e where UPPER(.word)=UPPER(@english)); 
     end 

     declare @intKuId int=-1; 
     exec @intKuId=Check_Kurdish_Word @[email protected]; 

     if @intKuId =-1 
     begin 
      insert into kurdish_table values(@kurdish, @kurdish_category); 

      set @identityKurdish = SCOPE_IDENTITY(); 
     end 
     else 
     begin 
      set @identityKurdish = (select k.kurdish_id from kurdish_table k where upper(k.word)=upper(@kurdish)); 
     end 

     declare @translated int =0; 

     exec @translated = Check_Translation @english_id = @identityEnglish, @kurdish_id = @identityKurdish; 

      if @translated=0 
     begin 
      insert into transactions values(@identityEnglish, @identityKurdish); 
      set @result = 1; 
     end 
     else 
     begin 
      set @result = 2; 
     end 
    end 
    else 
    begin 
     set @result = 0; 
    end 
END 

這是第一個功能:

ALTER FUNCTION [dbo].[Check_English_word] 
(
@text nvarchar(70) 
) 
RETURNS int 
AS 
BEGIN 

    DECLARE @Result int 
    set @Result=-1; 

    if @text is not null 
    begin 

     SELECT @Result = e.english_id 
      from english_table e 
      where UPPER(e.word) = UPPER(@text); 
    end 

    RETURN @Result 
END 

二級功能:

ALTER FUNCTION [dbo].[Check_Kurdish_Word] 
(
@word nvarchar(70) 
) 
RETURNS int 
AS 
BEGIN 
    DECLARE @Result int 
    set @Result=-1; 

if @word is not null 
    begin 
     SELECT @Result = k.kurdish_id 
      from kurdish_table k 
      where UPPER(k.word) = UPPER(@word); 
    end 

    RETURN @Result 
END 
+0

它應該是'@ english_category'而不是'@ englsih_category'(只是一個錯字) –

回答

1

你在這個行業缺少e

 set @identityEnglish=(select e.english_id from english_table e 
       where UPPER(.word)=UPPER(@english)); 

將其更改爲

 set @identityEnglish=(select e.english_id from english_table e 
       where UPPER(e.word)=UPPER(@english)); 

此外,它是很好的做法,指定列執行INSERT時 - 即

insert into english_table values(@english,@englsih_category); 

應該是

insert into english_table (word, category) values(@english,@englsih_category); 
+0

謝謝你是多麼愚蠢我是hhhhh – danarj

相關問題