2010-06-23 19 views
4

다음 오류가 발생합니다.개체 또는 열 이름이 없거나 비어 있습니다.

개체 또는 열 이름이 없거나 비어 있습니다. SELECT INTO 문의 경우 각 열에 이름이 있는지 확인하십시오. 다른 명령문의 경우 빈 별칭 이름을 찾으십시오. ""또는 []로 정의 된 별명은 허용되지 않습니다. 별명으로 이름이나 단일 공백을 추가하십시오.

CREATE   PROC [dbo].[Sp_Table1] @ctlg_ipt_event_id int 
AS 
SET NOCOUNT ON 

DECLARE @current_status NCHAR(1), @ready_status_code NCHAR(1) 
DECLARE @current_action NCHAR(1), @ready_action_code NCHAR(1), @done_action_code NCHAR(1) 
DECLARE @pst_user_id int 


SELECT @current_status = status_code 
     ,@current_action = action_code 
     ,@pst_user_id = last_mod_user_id 
    FROM merch_ctlg_ipt_event 
WHERE ctlg_ipt_event_id = @ctlg_ipt_event_id 

Select @ready_status_code = 'o' 
, @ready_action_code = 'a' 
, @done_action_code = 'b' 

IF @current_status <> @ready_status_code OR @current_action <> @ready_action_code 
BEGIN 
RETURN 
END 


BEGIN TRAN 

declare @rows int 
    ,@err int 
    ,@i int 
    ,@name nvarchar(50) --COLLATE SQL_AltDiction_Pref_CP850_CI_AS 
      ,@resolved_View_Name_category_id int 
      ,@xref_value int 
      ,@availability_start_date datetime 
      ,@availability_end_date datetime 
      ,@status_code int 
      ,@last_mod_user_id int 
      ,@CT datetime 
      ,@supplier_id int 
      ,@View_Name_id int 
    select @i = 1 
     ,@CT = current_timestamp 

Select Distinct mc.name, 
    mc.resolved_View_Name_category_id, 
    mc.xref_value, 
    mc.availability_start_date, 
    mc.availability_end_date, 
    mc.status_code, 
    CASE WHEN mc.last_mod_user_id = 42 
     THEN @pst_user_id 
     ELSE mc.last_mod_user_id 
     END as last_mod_user_id, 
    CURRENT_tsp 
    ,IDENTITY(int,1,1) as rn 
    ,si.supplier_id 
    ,si.View_Name_id 
into #temp 
FROM View_Name AS si 
JOIN merch_ctlg_ipt_View_Name AS mc 
    ON mc.supplier_id = si.supplier_id 
    AND mc.resolved_View_Name_id = si.View_Name_id 
    AND mc.cat_imp_event_id = @ctlg_ipt_event_id 
    AND mc.accept_flag = 'y' 
WHERE si.shipper_flag = 'n' 
select @[email protected]@ROWCOUNT,@[email protected]@error 
if @rows > 0 and @err=0 
Begin 

    While @i <[email protected] 
     begin 
      SElect @name = name, 
        @resolved_View_Name_category_id = resolved_View_Name_category_id, 
        @xref_value = xref_value, 
        @availability_start_date = availability_start_date, 
        @availability_end_date = availability_end_date, 
        @status_code = mc.status_code, 
        @last_mod_user_id =last_mod_user_id , 
        ,@[email protected]+1 
        ,@supplier_id=supplier_id 
        ,@View_Name_id=View_Name_id 
       from #temp 
      Where [email protected] 
      UPDATE View_Name 
       SET name = @name, 
        View_Name_category_id = @resolved_View_Name_category_id, 
        xref_value = @xref_value, 
        availability_start_date = @availability_start_date, 
        availability_end_date = @availability_end_date, 
        status_code = @status_code, 
        last_mod_user_id = @last_mod_user_id , 
        last_mod_timestamp = @CT 
      Where @sup_id = supplier_id 
       AND @View_Name_id = View_Name_id 
       AND shipper_flag = 'n' 
      IF @@ERROR > 0 
      BEGIN 
       ROLLBACK TRAN 
       RETURN 
       END 
      End 
End 


UPDATE 
merch_ctlg_ipt_event 
SET action_code = @done_action_code, 
    last_mod_timestamp = @CT 
WHERE ctlg_ipt_event_id = @ctlg_ipt_event_id 

IF @@ERROR > 0 
BEGIN 
ROLLBACK TRAN 
RETURN 
END 


COMMIT TRAN 
Return 
go 

당신이 도와주세요 수 : 아래의 쿼리 쇼

?

+0

불가능하다 쿼리에서 참조되는 모든 테이블과 뷰의 구조를 알지 못해도 알 수 있습니다. 모든 항목을 살펴보고 쿼리에서 열 참조가 누락되어 있는지 확인하십시오. – Oded

+1

+1 간단히'IDENTITY (int, 1,1)'에 대해서는 이전에 본 적이 없었습니다. –

답변

5

현재 행 또한

@last_mod_user_id =last_mod_user_id , 
        ,@[email protected]+1 

오류 메시지에 아마 관련이없는 2 개 쉼표가 있지만 선

  Where @sup_id = supplier_id 

하지만, 선언 된 변수가하면에 @supplier_id

관련 문제