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

Not much to go on here. Which statement times out? Are there indexes on your tables to help with the selection? What is the timeout value set to on the connection? What is your server memory? Are there governor policies set? Does the insert cause an autogrow condition on the database? How's your disk space? Full recovery model? Any other transactions colliding? User load on the server?

These are just a few possibilities to help analyze your situation. Best of luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.