이런 종류의 문제는 이전 질문에서 비롯된 것입니다.하지만 다른 방법으로 생각해 봤는데, 내가 뭘하려고했는지,보기에서 할 수 없다는 것을 알았습니다. 기능.함수를 만들 때 오류가 발생했습니다.
그러나 나는이 스레드의 바닥에 부착 된 코드를 가지고 있지만 이러한 오류를 얻고있다 :
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Relationship_Code_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Relationship_Code_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Relationship_Code_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Relationship_Code_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Relationship_Code_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Relationship_Code_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Relationship_Code_ID" could not be bound.
Msg 444, Level 16, State 2, Procedure fn_COT_TEST, Line 27 [Batch Start Line 0]
Select statements included within a function cannot return data to a client.
Msg 4104, Level 16, State 1, Procedure fn_COT_TEST, Line 29 [Batch Start Line 0]
The multi-part identifier "Contact_Group_Contacts_T.Main_Group_Contact_BT" could not be bound.
Msg 444, Level 16, State 2, Procedure fn_COT_TEST, Line 29 [Batch Start Line 0]
Select statements included within a function cannot return data to a client.
Msg 455, Level 16, State 2, Procedure fn_COT_TEST, Line 29 [Batch Start Line 0]
The last statement included within a function must be a return statement.
내 코드는 다음과 같습니다. 나는 열심히 노력했지만 완전히 붙어 있습니다. 내가 도대체 뭘 잘못하고있는 겁니까?
CREATE FUNCTION [dbo].[fn_COT_POA] (@CONTACT_ID INT)
RETURNS VARCHAR
AS
BEGIN
DECLARE @COUNT INT;
SET @COUNT =
(select COUNT(CONTACT_ID)
from Contact_Group_Contacts_T
where CONTACT_ID = @CONTACT_ID)
RETURN @COUNT
IF @COUNT > 1
select @CONTACT_ID where Contact_Group_Contacts_T.Relationship_Code_ID in (2801,2802,2803,2804,2805,2806,2807)
ELSE
select @CONTACT_ID where Contact_Group_Contacts_T.Main_Group_Contact_BT = 1
END
GO
내가 뭘하려고 그들이 가지고하지 않은 경우 그 관계 코드 ID의 다음 1.
로 main_group_contact_bt 플래그가 연락처를 선택, 그 관계 코드 ID의의가있는 경우에만 연락처 선택이다 감사합니다 댄
태그 DBMS에 당신은 다시 사용하고있어. 이 코드는 제품마다 다릅니다. – jarlh
왜이 회선이 기능 중에 있습니까? 'return @ count' 함수는 무엇인가를 반환 한 후 정지하려고합니다. – SqlZim
@SqlZim - 힌트를 줄 수있는 온라인 샘플을 추적하고있었습니다. 내가해야하는지 안했는지 나는 몰랐다. 어쨌든 꺼내면 작동하지 않습니다. – dgoodwin