---
title: "Store Procedure is used to Insert and Update Data"  
description: "Create proc [dbo].[sp_tbStudentInsertUpdate]       @iStudentID_PK int,   @sStudentName varchar(50),   @sClass varchar(50),   @sTrade varchar(50),   @s"  
author: "Love Chahal"  
published: 2013-02-19  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/448/store-procedure-is-used-to-insert-and-update-data  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Store Procedure is used to Insert and Update Data

Create proc [dbo].[sp_tbStudentInsertUpdate]\
(\
\
@iStudentID_PK [int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql),\
@sStudentName [varchar](https://www.mindstick.com/forum/161878/what-is-the-difference-between-nvarchar-and-varchar)(50),\
@sClass varchar(50),\
@sTrade varchar(50),\
@sAddress varchar(50),\
@iFee int\
)\
as\
if [exists](https://www.mindstick.com/forum/158947/how-do-you-use-the-exists-operator-to-check-for-the-existence-of-records-in-a-subquery)([select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) * from tbStudent where iStudentID_PK=@iStudentID_PK)\
begin\
[update](https://www.mindstick.com/forum/265/ajax-update-panel) tbStudent set sStudentName=@sStudentName, sClass=@sClass, sTrade=@sTrade, sAddress=@sAddress, iFee=@iFee where iStudentID_PK=@iStudentID_PK\
return 1\
[end](https://yourviews.mindstick.com/view/88503/us-iran-war-live-updates-trump-says-us-in-no-rush-to-end-iran-war)\
else\
begin\
[insert](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net) into tbStudent( sStudentName, sClass, sTrade, sAddress, iFee)[values](https://www.mindstick.com/forum/327/sum-textbox-values)\
( @sStudentName, @sClass, @sTrade, @sAddress, @iFee)\
return 0\
end\

---

Original Source: https://www.mindstick.com/blog/448/store-procedure-is-used-to-insert-and-update-data

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
