I have the following query:

```
DECLARE @codeItem VARCHAR(100);
DECLARE @Price DECIMAL(18, 5);
DECLARE @EndDate DATE;
DECLARE @StartDate DATE;

DECLARE Cur CURSOR FOR
    SELECT *
    FROM myTable

OPEN Cur

FETCH NEXT FROM Cur INTO @codeItem, @Price, @EndDate, @StartDate

WHILE @@fetch_status = 0 BEGIN

    EXEC sp_Proc @codeItem, @Price, @EndDate, @StartDate

    FETCH NEXT FROM Cur INTO @codeItem, @Price, @EndDate, @StartDate
END

CLOSE Cur
DEALLOCATE Cur

```

Stored procedure `sp_Proc`:

```
UPDATE SRC
SET enddate = DATEADD(DAY, -1, @StartDate)
FROM test SRC
WHERE codeItem = @codeItem
    AND (@StartDate BETWEEN startdate AND enddate)

INSERT INTO test (codeItem, price, startdate, enddate)
VALUES (@codeItem, @price, @StartDate, @EndDate)

```

How can I optimize the queries?

Delete the cursor?

How can I make it faster?