This is my Update / Insert command for SQL, first it tries to update a record, then if nothing is updated it inserts new data and returns the new ID.
I use this when I want to use one form for all my updates and inserts.
Create PROCEDURE [dbo].[updateQualifcation]
-- Add the parameters for the stored procedure here
@Field varchar(300),
@TableID int = 0
AS
BEGIN
SET NOCOUNT ON;
UPDATE [summit-skills].[dbo].[tblQualification]
SET [fldField] = @Field
WHERE fldTableID = @TableID
IF @@ROWCOUNT = 0
INSERT INTO [summit-skills].[dbo].[tblQualification]
([fldField])
VALUES
(@Field)
select @@IDENTITY
END
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5