CREATE PROCEDURE [dbo].[BO_AddKnokTag]
	@KnokId int,
	@Name VARCHAR(255) = NULL,
	@AnalysisTypeId int,
	@AnalysisTagId int
AS
	IF @AnalysisTagId = -1 
		INSERT KnokCustomTags (KnokId, AnalysisTagTypeId, Name) VALUES(@KnokId, @AnalysisTypeId, @Name)
	ELSE
		INSERT KnokAnalysisTags (KnokId, AnalysisTagId) VALUES(@KnokId, @AnalysisTagId)
	
	EXEC BO_GetKnokTags @KnokId, @AnalysisTypeId, @AnalysisTagId, @Name
RETURN 0
