Diese Art von folgt auf meine vorherige Frage, aber ich habe es anders gegangen, wie ich herausgefunden habe, was ich versuchte zu tun, kann ich nicht in einer Ansicht, es muss ein sein Funktion.Fehler beim Erstellen der Funktion
Allerdings habe ich den Code bekam an der Unterseite dieses Themas angebracht, aber ich erhalte diese Fehler:
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.
Mein Code ist unten. Ich habe mein Bestes versucht, bin aber völlig festgefahren. Was mache ich falsch?
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
Was ich versuche, ist nur ausgewählte Kontakte zu tun, die diese Beziehung Code-IDs haben, wenn sie nicht jene Beziehung Code-IDs dann wählen Sie den Kontakt, der die main_group_contact_bt Flagge als 1. hat bekommen haben
dank Dan
Tag die dbms Sie verwende es. Dieser Code ist produktspezifisch. – jarlh
Warum haben Sie diese Zeile in der Mitte Ihrer Funktion? 'return @ count' Ihre Funktion möchte anhalten, nachdem sie etwas zurückgegeben hat. – SqlZim
@SqlZim - Ich habe ein Beispiel online verfolgt, das mir Hinweise geben könnte. Ich wusste nicht, ob ich sollte oder nicht. Funktioniert nicht, wenn ich es trotzdem herausnehme – dgoodwin