如何使用存储过程更新项目列表 [英] How to update list of items using Stored Procedure
问题描述
我有一个特定ID的数据列表,我需要编辑和更新这些值。
我的要求如下:
这是我的SQL表格:
ItemID ItemName TypeID
123 abcdc 232
123 acd 12
123 cgd 23
我需要编辑任何ItemName并更新它。例如:
我需要编辑abcdc并将其更新为hello和TypeID 12到45.
我需要为此创建更新sp。
请帮帮我
尝试:
CREATE PROCEDURE MyUpdate
AS
BEGIN
更新 MyTable SET ItemName = ' hello' WHERE ItemName = ' abcdc'
UPDATE MyTable SET TypeID = 45 WHERE TypeID = 12
END
GO
并使用它编写存储过程。检查 Sql Server - 如何编写存储过程在Sql server中 [ ^ ]
最后使用.net来调用此存储过程
使用ADO.Net调用更新SQL Server存储过程 [ ^ ]
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
Try:
CREATE PROCEDURE MyUpdate AS BEGIN UPDATE MyTable SET ItemName='hello' WHERE ItemName='abcdc' UPDATE MyTable SET TypeID=45 WHERE TypeID=12 END GO
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[^]
这篇关于如何使用存储过程更新项目列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!