The text of this article is not in this database — only its details are. Read it on the old site: Select, Insert, Update, Delete Using Stored Procedure in SQL Server
54 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.

Nurman AdePosted Mar 18, 2022, 6:28 AM
How to call specific stored procedure. For example Exec Masterinsertupdatedelete where StatementType = 'Select'
Máÿàñk GhìldíÿâlPosted Feb 16, 2022, 3:49 PM
How to check select query in this stored procedure
roger simanjuntakPosted Dec 19, 2021, 5:29 PM
Msg 208, Level 16, State 6, Procedure Masterinsertupdatedelete, Line 2 [Batch Start Line 46]Invalid object name 'Masterinsertupdatedelete'.
Mohamed BassunyPosted Dec 8, 2020, 5:10 AM
This code is perfect but only one thing is not as i want , how can i make one Stored Procedure when i don't want to pass "id" in insert only , but i need it for other ? thanks
Mohamed BassunyPosted Dec 7, 2020, 11:10 AM
Thanks this is perfect
Umesh DaiyaPosted Apr 9, 2020, 5:21 PM
In this how i can stop duplicate employee name
Chittaranjan SwainPosted Oct 30, 2019, 10:10 AM
Nice article...
Sandipta SahuPosted May 9, 2019, 12:22 AM
How to data-bind to grid view with parameter
Sandipta SahuPosted May 8, 2019, 11:35 PM
How to pass parameters for select comment help me/
Pramod PeyyalaPosted Jan 8, 2019, 1:29 AM
Nice Article
Piyush AgarwalPosted Mar 9, 2018, 5:59 AM
Thanks for sharing this...
Mohit SharmaPosted Jul 14, 2017, 3:54 AM
If i want to update the stored procedure table column not having any parameters than how it will ??
manish kumarPosted May 19, 2017, 10:50 AM
My query is not working Display Must Declare the Scalar variable
Sa HulPosted Mar 11, 2017, 3:22 AM
How to write condition in asp.net for (insert and update, delete) in storedprocedure
kalu singh raoPosted Jul 9, 2016, 10:39 AM
Nice...
Noor MowafaqPosted Dec 7, 2015, 4:31 AM
I'm having an error when i execute the procedure saying that the procedure name is invalid and i don't know how to deal with it
nofact nofacePosted May 31, 2015, 3:13 AM
I search internet for 3 hour to find this page thank you
Imran AhmedPosted Jan 30, 2015, 11:51 AM
thanks a lot,
Alex MejikPosted Oct 22, 2014, 3:25 AM
when i execute it from SQL server the insert works fine----exec MasterInsertUpdateDelete_student null,'test23','lastname','12/12/2012','London','434343434','Insert'
Alex MejikPosted Oct 22, 2014, 3:24 AM
from c$ i call it - db_contex.MasterInsertUpdateDelete_student(null,fname, lname, bdate, adress, phone,"Insert");
Alex MejikPosted Oct 22, 2014, 3:23 AM
Hey,thanks a lot for the code, but i get an error saying---------- The data reader is incompatible with the specified 'UniDbModel.MasterInsertUpdateDelete_student_Result'. A member of the type, 'Id', does not have a corresponding column in the data reader with the same name. -------------- Select works fine, what is the problem?
Vaka SivaramireddyPosted Oct 14, 2014, 1:07 AM
nice sir .simply super
Shreya SoniPosted Aug 30, 2014, 4:15 AM
Its useful.. I need a common stored procedure to update all tables.. A common for all... Plz help me..
Aman PetwalPosted Feb 5, 2014, 10:52 AM
its verry helpfull thanx sir ji
Tariq HashmiPosted Jan 29, 2014, 5:57 AM
Thanks sir ji
nupur kadamPosted Nov 27, 2013, 7:43 AM
thanks
durgesh pandeyPosted Nov 5, 2013, 9:20 AM
Thanks!!!!!!!!!!!!! nice 1
Saikat Kumar DeyPosted Aug 7, 2013, 6:30 AM
thanx sir.. i invited u to chat.. my email id is [email protected]
Rohatash KumarPosted Aug 7, 2013, 6:28 AM
My Email-id- [email protected]
Saikat Kumar DeyPosted Aug 7, 2013, 6:26 AM
Sir.. is there any other way to talk 2 u like gtalk or anything else?
Rohatash KumarPosted Aug 7, 2013, 6:22 AM
Saikat, if you have any problem related to sql server and .net. Please Feel free to ask me.
Saikat Kumar DeyPosted Aug 7, 2013, 6:15 AM
ok sir...
Rohatash KumarPosted Aug 7, 2013, 6:14 AM
Saikat you can run directly using exec command on the page.
Saikat Kumar DeyPosted Aug 7, 2013, 6:05 AM
In sql server.. actually i just passed 4th yr of btech n joined a company. so im learning of working with swql server stored procedure thats why.
Rohatash KumarPosted Aug 7, 2013, 5:55 AM
Saikat, You want that in asp.net page or SQL Server.
Saikat Kumar DeyPosted Aug 7, 2013, 5:41 AM
i mean t say that if i want to show the update insert delte etc all four in one page then how to do it sir?
Saikat Kumar DeyPosted Aug 7, 2013, 5:37 AM
u mean first insert code then go then update code then go like these?
Rohatash KumarPosted Aug 7, 2013, 5:33 AM
Saikit, you are executing more than one sql statement on the same page. so you can use go statement to separate SQL statements.
Saikat Kumar DeyPosted Aug 7, 2013, 5:23 AM
Hello sir.. i implemented all the process and it done well.... thanx for such a awesome tools for the begineersbut i hav a question.. that is when i did the insert, update or delte in the same page where i made the procedure there its showing that commands executed succesfully but in the databse i cant find any change but iwhen im writing the same code in a new query option then its working.. can u plz help me in understood this?
Rohatash KumarPosted Apr 2, 2013, 2:31 AM
You can make @StatementType as out parameter. And use its string value in application.tue ngo tri
Tue NgoTriPosted Apr 2, 2013, 12:17 AM
please help, I want to code your article. thanks sir
myintmyint htayPosted Dec 28, 2012, 2:46 AM
Thanks Sir:
roolerPosted Dec 14, 2012, 7:52 AM
I got error:Invalid object name 'MasterInsertUpdateDelete'. it happends when try to excecute alter table
Rohatash KumarPosted Dec 3, 2012, 6:53 AM
Thanks Reza.
reza parmarPosted Dec 3, 2012, 6:29 AM
ok.
MattPosted Oct 10, 2012, 9:26 AM
It is not a good idea to combine select/Insert/Update/Delete within a single stored procedure for multiple reasons. Firstly, you loose atomicity within your code; if you'd developed the code within a class you wouldn't have bundle all the logic into 1 method, you'd have 4 seperate ones. The same applies with a stored procedure. It's easier to unit test each procedure individually instead testing in a lump. It becomes a lot more difficult to maintain the code when the logic starts getting complex. @StatementType adds nothing to the overall operation other than a piece of data to make a decision on; you've made your call slower by virtue of having more data to pass and some conditional logic. If the calling application calls the relevant procedure (INSERT for instance) then there is no condition check to apply and you've not had to pass "INSERT" through the network. There are a whole host of locking issues where two people could try and update the same data at the same time, alternative update and delete. And a host of other reasons as to why this is not a good idea. Make database objects atomic as you would methods in a class - it's easier, cleaner, faster, and more maintainable.
Nomi MughalPosted Apr 3, 2012, 2:49 AM
But how can I call this in my c# application.Kindly help me
vikash kumarPosted Apr 1, 2012, 5:09 PM
THANKS PLZ TELL ME HOW TO USE IT IN ASP.NET OR HOW TO CALL THIS PROCEDURE IN ASP.NET
Kieran CallaghanPosted Dec 19, 2011, 11:38 AM
Nice article Rohatash very helpful to us beginners Kind Regards, Kieran