Beanie posted on March 9, 2009 16:06

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 

Posted in: Development  Tags: , , , ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Add comment


 
  Country flag

biuquote
  • Comment
  • Preview
Loading



Page List

Search Blog

Tag Cloud

Recent Comments

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010 Beanie