title: In stored procedure if null value found it should skip that insert query
body: <p>I have 2 tables one is </p>
  
  <pre><code>peson contains(personid Identity, firstname,Lastname,PlaceOfBirth,Gender) 
  </code></pre>
  
  <p>and another </p>
  
  <pre><code>Education contains (Eduid identity, egreename,boardUniver,yearOfPassing,obtainedMarks, personid)
  </code></pre>
  
  <p>now my problem is that each person have more than 1 degree, but some have 1 or 2 degree, so how can i skip the insert queries?</p>
  
  <p>First Table</p>
  
  <pre><code>Create table person(personid int Identity(1,1) primary key, firstname nvarchar(40), Lastname nvarchar(40), PlaceOfBirth nvarchar(40), Gender nvarchar(10))
  </code></pre>
  
  <p>Second Table</p>
  
  <pre><code>create table Education(Eduid int identity(1,1) primary key, Degreename nvarchar(40), boardUniver nvarchar(40), yearOfPassing nvarchar(40), obtainedMarks numeric(10,2), personid int, 
  constraint fk_eduPerson foreign key (personid) references person(personid))
  </code></pre>
  
  <p>Procedure to store information</p>
  
  <pre><code>Create procedure EmpDetails
  (
      @Firstname nvarchar(40),  @Lastname nvarchar(40), @PlaceOfBirth nvarchar(40), @Gender nvarchar(8), 
      @Degreename0 int, @boardUniver0 nvarchar(40), @yearOfPassing0 nvarchar(20), @obtainedMarks0 int,
      @Degreename1 int, @boardUniver1 nvarchar(40), @yearOfPassing1 nvarchar(20), @obtainedMarks1 int,
      @Degreename2 int, @boardUniver2 nvarchar(40), @yearOfPassing2 nvarchar(20), @obtainedMarks2 int, 
  )
  AS BEGIN
  declare @personid int
  INSERT INTO person(firstname,Lastname,PlaceOfBirth,Gender) values(@firstname,@Lastname,@PlaceOfBirth,@Gender)
  SELECT @personid=@@IDENTITY
  if(@Degreename0 !=NULL)
      BEGIN
      INSERT INTO Education(Degreename,boardUniver,yearOfPassing,obtainedMarks, personid) values (@Degreename0,@boardUniver0,@yearOfPassing0,@obtainedMarks0, @personid)
      END
  IF(@Degreename1 !=null)
    BEGIN
      INSERT INTO Education(Degreename,boardUniver,yearOfPassing,obtainedMarks, personid) values (@Degreename1,@boardUniver1,@yearOfPassing1,@obtainedMarks1, @personid)
    END
  IF(@Degreename2!=null)
     BEGIN
      INSERT INTO Education(Degreename,boardUniver,yearOfPassing,obtainedMarks, personid) values (@Degreename2,@boardUniver2,@yearOfPassing2,@obtainedMarks2,@personid)
      END
  END
  </code></pre>
  
  <p>This is not working.. this inserts all rows empty.. is there any other solution to do this?
  Please give suggestion if any other.. Thanks </p>