Merhaba

Dün yeni bir cursor'a daha ihtiyacım oldu,

Belki faydası olabilir paylaşıyorum.

DECLARE @email VARCHAR(250) 
DECLARE @TANIM VARCHAR(256) 
DECLARE @FCCM1_ID numeric(12,0) 
DECLARE @COUNT int
 

set @COUNT = 0
 
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) 
 
DECLARE db_cursor CURSOR FOR  
SELECT email from unsubscribed_members_export_ef5$ 

 
OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @email
 
WHILE @@FETCH_STATUS = 0   
BEGIN   
       

	   if EXISTS (select TANIM FROM FCCM8_T WHERE TANIM = @email) 
	   begin
		
		
		select @FCCM1_ID  = FCCM1_ID  FROM FCCM8_T WHERE TANIM = @email

		IF NOT EXISTS (select FCCM1_ID from FCCM6 WHERE FCCM1_ID = @FCCM1_ID)
		begin
			insert FCCM6(FCCM1_ID,FSMUSOZEL_ID,FSOZLDEGER_ID) values( @FCCM1_ID, 79, 73)
			set @COUNT = @COUNT + 1
			print cast(@COUNT as varchar(10)) + ' '+ @email + ' ' + cast( @FCCM1_ID as varchar(10))

		end
		

	   end
 
       FETCH NEXT FROM db_cursor INTO @email
END  
 
print cast(@COUNT as varchar(10)) + ' '+ @email

CLOSE db_cursor   
DEALLOCATE db_cursor

Umarım faydası olur . İyi çalışmalar.