title: How to write a stored procedure using functions?
body: <p>Hi all I am new to functions so am having a bit starting trouble here </p>
  
  <p>I have two tables like this</p>
  
  <p><strong>Bugs</strong></p>
  
  <pre><code>BugID|Title|ProjectName|CreatedBy
  </code></pre>
  
  <p><strong>BugHistory</strong></p>
  
  <pre><code>BughistoryID|BugID|Assignedto|ToStatus|FromStatus
  </code></pre>
  
  <p>I want to write an insert stored procedure for the <code>Bugs</code> table where I will insert <code>[Title]|[ProjectName]</code> and <code>[CreatedBy]</code> into the <code>bugs</code> table and <code>BugID</code> has Identity and primary key.</p>
  
  <p>After that, I have to insert the <code>BugID</code> of the new title and <code>Tostatus</code> into the <code>BugHistory</code> table. These two steps should be done in a single stored procedure.</p>
  
  <p>I want a select statement where I have to show the bugs table in gridview with <code>[AssignedTo]</code> and <code>[Tostatus]</code> columns from <code>BugHistory</code> table. How can I use functions for this both procedure s any ideas please?</p>