Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have a list of data for a particular ID and I need to edit and update the values.
My requirement is as follows:
This is my SQL table:
ItemID ItemName TypeID
123 abcdc 232
123 acd 12
123 cgd 23
I need to edit the any of the ItemName and update it. For example:
I need to edit abcdc and update it to hello and TypeID 12 to 45.
I need to create an update sp for that.
Please help me
Posted

Try:
SQL
CREATE PROCEDURE MyUpdate
AS
BEGIN
   UPDATE MyTable SET ItemName='hello' WHERE ItemName='abcdc'
   UPDATE MyTable SET TypeID=45 WHERE TypeID=12
END
GO
 
Share this answer
 
Comments
My Doubt 28-Jun-14 5:01am    
OriginalGriff,
No its not like that I need to update my table on the basis of itemID. So where condition is on the basis of ItemID and the values will be get at the run time. no hard coded values.
You need to write SQL UPDATE Statement[^]
and write stored procedure by using that. check Sql Server - How to write a Stored procedure in Sql server[^]
Finally call this stored procedure using .net
Calling Update SQL Server Stored Procedures using ADO.Net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900