This SP is working well. But when recordcount in dbo.PTSGELEN is over 1000000 approx. it comes timeout error.
ALTER PROCEDURE [dbo].[PTS2Tabloya]
@KOLETIK nvarchar(40),
@SIL tinyint ,
@EKLENEN int OUT
AS
BEGIN
SET NOCOUNT ON;
set @EKLENEN = 0
IF @SIL=0 AND LEN(@KOLETIK)=20
begin
INSERT INTO dbo.URUNGIR (GTIN,SN,XD,BN,CLABEL,SLABEL)
SELECT GTIN,SN,XD,BN,CLABEL,SLABEL FROM dbo.PTSGELEN WHERE
(CLABEL = @KOLETIK OR SLABEL = @KOLETIK);
set @EKLENEN = @@Rowcount ;
END;
IF @SIL=1 AND LEN(@KOLETIK)=20
BEGIN
DELETE FROM dbo.URUNGIR WHERE (CLABEL = @KOLETIK OR SLABEL = @KOLETIK) ;
set @EKLENEN = @@Rowcount ;
END;
END