I will first explain the context. I want to read serie subtitles contained in .srt files. I have already done the part of extracting the words from the files (and how many times the word appears for a serie) but when it comes to inserting the data in my SQL Server database, it takes more and more time to do the updates or inserts because i am checking if the word exists or not. I call a stored procedure from C# with the following parameters : the word, how many times it appears in my files, the serie name.ALTER PROCEDURE [dbo].[INSERT_WORD_FOR_SERIE]    @word nvarchar(50),     @counter int,    @serie nvarchar(50)ASBEGIN    DECLARE @idSerie AS int    DECLARE @idWord AS int    SELECT @idWord = IDWORD FROM WORD WHERE WORD=@word;    IF @idWord IS NOT NULL        BEGIN            SELECT @idSerie = IDSERIE FROM SERIE WHERE SERIE=@serie;            IF EXISTS (SELECT counter FROM APPEARS WHERE IDWORD=@idWord AND IDSERIE=@idSerie)                BEGIN                    UPDATE APPEARS SET counter = counter + @counter WHERE IDWORD=@idWord AND IDSERIE=@idSerie;                END            ELSE                BEGIN                    INSERT INTO APPEARS VALUES (@idWord, @idSerie, @counter);                END        END    ELSE        BEGIN            INSERT INTO WORD VALUES (@word);            SELECT @idWord = IDWORD FROM WORD WHERE WORD=@word;            SELECT @idSerie = IDSERIE FROM SERIE WHERE SERIE=@serie;            INSERT INTO APPEARS VALUES (@idWord, @idSerie, @counter);        ENDENDI have inserted only two series and I can already see that it is taking more and more time to insert or update one word.Can you see any improvements that can be done or different way of doing what I want more efficiently ?
Using UPSERT to maintain word counts for subtitles
performance;sql;sql server