title: How to return value 1 stored procedure
body: <p>I have written a stored procedure for inserting name and email address:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[usp_Referral_Email]
      @user_key varchar(36),
      @name nvarchar(100),    
      @email nvarchar(500),
      @result int output
  AS
  BEGIN
      DECLARE @username Nvarchar(500)
      DECLARE @useremail Nvarchar(500)
      DECLARE @CusrsorID CURSOR
  
      SET @CusrsorID = CURSOR FOR
          SELECT Value,Value1
          FROM ufn_split_string(@name,@email) 
  
      OPEN @CusrsorID
  
      FETCH NEXT FROM @CusrsorID INTO @username, @useremail
  
      WHILE @@FETCH_STATUS = 0
      BEGIN
          declare @user nvarchar(36)
  
          begin try
          begin transaction trans_Referral_Email      
  
              IF NOT EXISTS (SELECT 1 FROM dbo.C_User_Credentials 
                             WHERE email = @useremail)
              BEGIN
                  IF NOT EXISTS (SELECT 1 FROM dbo.Referral_Email 
                                 WHERE R_Email = @useremail)
                  BEGIN
                      INSERT INTO dbo.Referral_Email (CFK_C_UP_key, R_Name, R_Email)
                      VALUES (@user_key, @username, @useremail)               
  
                      SET @result = 1
                  END
                  ELSE
                  BEGIN
                      SET @result = 0
                  END
              END
              ELSE
              BEGIN
                  SET @result = 0
              END
  
              COMMIT transaction trans_Referral_Email
          end try
          begin catch
              rollback transaction trans_Referral_Email
              set @result=ERROR_MESSAGE()
          end catch
  
  
          FETCH NEXT FROM @CusrsorID INTO @username, @useremail
      END
  
      CLOSE @CusrsorID
      DEALLOCATE @CusrsorID
  END
  </code></pre>
  
  <p>As a example I will pass value </p>
  
  <ol>
  <li><code>@name</code> = <code>ramesh,suresh,rahul</code></li>
  <li><code>@email</code> = <code>ramesh@gmail.com,suresh@gmail.com,rahul@gmail.com</code></li>
  </ol>
  
  <p>before inserting we checking condition  email address are exists or not, suppose email address is exist it will not insert into the table. 
  Now my problem is i will explain through example.  <strong>ramesh@gmail.com</strong> and <strong>suresh@gmail.com</strong> are new email address both email address are will insert into the table so return value is <strong>1</strong>  rahul@gmail.com already exist in table so it will insert into the table so return value will be <strong>0</strong> and output @return value will be <strong>0</strong> but we have inserted 2 email address so i need <strong>@return value should be 1 as out put</strong>. </p>
  
  <p>So my question is if at any place of email address is insert into the table  if one email address also insert output should be <strong>@return=1</strong> </p>