Updating stored procedure

I wanted to check with the SO community on any possible future issues doing it this way.Separate Procedures --INSERT Procedure CREATE PROCEDURE [dbo].[Add Data Type] @Type Name [nvarchar](255), @Type Property [nvarchar](255) AS BEGIN SET NOCOUNT ON; INSERT INTO Data Type(Type Name, Type Property) VALUES(@Type Name, @Type Property) SELECT SCOPE_IDENTITY() END --UPDATE Procedure CREATE PROCEDURE [dbo].[Set Data Type] @ID [int], @Type Name [nvarchar](255), @Type Property [nvarchar](255) AS BEGIN SET NOCOUNT ON; UPDATE Data Type SET Type Name = @Type Name, Type Property = @Type Property WHERE ID = @ID END EXEC Add Data Type @Type Name = 'Test Name', @Type Property = 'Test Property' --INSERT EXEC Set Data Type @ID = 42, @Type Name = 'Test Name', @Test Property = 'Test Property' --UPDATE CREATE PROCEDURE [dbo].[Set Data Type] @ID [int] = NULL, @Type Name [nvarchar](255), @Type Property [nvarchar](255) AS BEGIN SET NOCOUNT ON; UPDATE Data Type SET Type Name = @Type Name, Type Property = @Type Property WHERE ID = @ID IF @@ROWCOUNT = 0 INSERT INTO Data Type(Type Name, Type Property) VALUES(@Type Name, @Type Property) IF @ID IS NULL SELECT SCOPE_IDENTITY() END EXEC Set Data Type @Type Name = 'New Type Name', @Type Property = 'New Type Property' --INSERT EXEC Set Data Type @ID = 42, @Type Name = 'Updated Type Name', @Type Property = 'Updated Type Property' --UPDATE So far I have 15 type tables that I creating procedures for and am trying to cut down on the number of procedures created, however I don't want to sacrifice performance.Figure5 Stored Procedure to Check update Master Insert Update Delete - right click select execute stored procedure... Statement Type = 'Update' Figure6 Click on the ok Button.and check in the employee table with following updated data where id is 7.Until MERGE (and except in cases where, say, the app might not know if this item is new or existing), for DML I generally agree with you. Data Type ( ID int IDENTITY(1,1), Type Name nvarchar(255), [Type Property] nvarchar(255), CONSTRAINT PK_Data Type PRIMARY KEY (ID) ); INSERT dbo.Data Type(Type Name, [Type Property]) VALUES (N'name 1', N'property 1'); GO CREATE PROCEDURE dbo. Now open object explorer and select storeprocedure Master Insert Update Delete.Stored Procedure to Check Insert Statement Type = 'Insert' Master Insert Update Delete - right click select execute stored procedure... Figure3 Now for insert we fill the data in required field.

This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. By joining today you can post your own programming questions, respond to other developers questions, and eliminate the ads that are displayed to guests. This forum seemed like a party that died years ago!

section if you are using Entity Framework 5.0 with VS2012.

If you have existing stored procedures to Insert, Update and Delete the record in the database table then you can use those stored procedures for the CUD operation instead of the entity framework's default saving mechanism using Entity Set.

I am creating stored procedures for inserting and updating data in my SQL Server database.

At first I was creating a separate procedure for Add/Set but then I stumbled across a query that allows me to condense them into a single procedure.