Skip to main content

Difference between SQL Function and Stored Procedure

The main difference between functions and stored procedures  are given bellow:
Function(User Defined)
  1. It returns only one value
  2. We can’t use transaction in function
  3. Only have input parameter
  4. We can’t called SP from function
  5. We can’t use exception handling using Try-Catch block in function
  6. We can use function in select/where/having statement
Stored Procedure (Store Procedure)
  1. It returns zero, single or multiple values
  2. We can use transaction in SP
  3. Can have input/output parameter
  4. We can called function from SP
  5. We can use exception handling using Try-Catch block in SP
  6. We can’t use SP in select/where/having statement

Comments

Popular posts from this blog

List Controls: List Box and Drop Downlist

ASP.Net provides the controls: drop-down list, list box, radio button list, check box list and bulleted list. These control let a user choose from one or more items from the list. List boxes and drop-down list contain one or more list items. These lists could be loaded either by code or by the ListItem Collection Editor. Basic syntax for list box control: <asp:ListBox ID="ListBox1"        runat="server"        AutoPostBack="True"        OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"> </asp:ListBox> Basic syntax for a drop-down list control: <asp:DropDownList ID="DropDownList1"       runat="server"       AutoPostBack="True"       OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> </asp:DropDownList>

Sql CharIndex Function

The CHARINDEX  function returns the starting position of the specified expression in a character string. Example: Search for "t" in string "DotNetReceipe", and return position: SELECT CHARINDEX( 't' , 'DotNetReceipe' ) AS Position;