我有两个存储过程,一个用于 INSERT,第二个用于更新,我想将它们合并为一个,所以您能告诉我应该使用哪个状态吗?
CREATE PROCEDURE Tools
(@CategoryID_1 int,
@CategoryName_2 nvarchar(100),
@Description_3 ntext)
AS INSERT INTO Categories
(CategoryID,
CategoryName,
Description)
VALUES
(@CategoryID_1,
@CategoryName_2,
@Description_3)
去
CREATE PROCEDURE Tools1
(@CategoryID_1 [int],
@CategoryID_2 [int],
@CategoryName_3 [nvarchar](50),
@Description_4 [ntext],
AS UPDATE [Teachdb].[dbo].[Categories]
SET [CategoryID] = @CategoryID_2,
[CategoryName] = @CategoryName_3,
[Description] = @Description_4,
WHERE
( [CategoryID] = @CategoryID_1)
go
去