Know its not that efficient to have all the operations insertion updation and deletion in a single stored procedure. But
here u go.
Single Stored Procedure for insert update and delete
USE [CommunityPortal]
GO
/****** Object: StoredProcedure [dbo].[usp_MasterInsertUpdateDelete] Script Date: 09/22/2011 06:08:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:
-- Create date:
-- Description:
-- =============================================
ALTER PROCEDURE [dbo].[usp_MasterInsertUpdateDelete]
-- Add the parameters for the stored procedure here
@StatementType nvarchar(20) = "Insert"
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF @StatementType = 'Insert'
BEGIN
SELECT * FROM City ' Replace with Insert Code
END ELSE IF @StatementType = 'Update'
BEGIN
SELECT * FROM State ' Replace wwith Update Code
END ELSE IF @StatementType = 'Delete'
BEGIN
SELECT * FROM Country ' Replace with delete code
END
END
|