
CREATE FUNCTION GET_CSAPP_OPTIONS_FIELDS (@PROTOCOL_ID BIGINT)
RETURNS @output TABLE(PK BIGINT NOT NULL IDENTITY(1,1), Bezeichnung VARCHAR(55)  NULL, CHECKED BIT NULL)  
BEGIN 
		INSERT INTO @output(Bezeichnung,CHECKED)
		SELECT SUBSTRING(ISNULL(cof.OPTIONS_NAME, ''),1,55),CAST(ISNULL(cof.OPTIONS_VALUE,0) AS bit) FROM CSAPP_OPTIONS_FIELDS cof WHERE cof.PROTOKOLL_PK = @PROTOCOL_ID		
	RETURN  
END